diff --git a/src/constants/ExtensionState.ts b/src/constants/ExtensionState.ts index 36139f50..652b0910 100644 --- a/src/constants/ExtensionState.ts +++ b/src/constants/ExtensionState.ts @@ -13,5 +13,11 @@ export const ExtensionState = { Media: { Sorting: `frontMatter:Dashboard:Media:Sorting`, } + }, + + Updates: { + v7_0_0: { + dateFields: `frontMatter:Updates:v7.0.0:dateFields` + } } }; \ No newline at end of file diff --git a/src/helpers/Extension.ts b/src/helpers/Extension.ts index 0f9aef40..3be287d7 100644 --- a/src/helpers/Extension.ts +++ b/src/helpers/Extension.ts @@ -1,6 +1,6 @@ import { basename } from "path"; import { extensions, Uri, ExtensionContext, window, workspace, commands, ExtensionMode, DiagnosticCollection, languages } from "vscode"; -import { EXTENSION_NAME, GITHUB_LINK, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, EXTENSION_BETA_ID, EXTENSION_ID, ExtensionState } from "../constants"; +import { EXTENSION_NAME, GITHUB_LINK, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, EXTENSION_BETA_ID, EXTENSION_ID, ExtensionState, CONFIG_KEY } from "../constants"; import { Notifications } from "./Notifications"; import { Settings } from "./SettingsHelper"; @@ -137,23 +137,29 @@ export class Extension { Settings.createTeamSettings(); } - // Migration scripts can be written here - const publishField = Settings.inspect(SETTING_DATE_FIELD); - const modifiedField = Settings.inspect(SETTING_MODIFIED_FIELD); + const hideDateDeprecation = await Extension.getInstance().getState(ExtensionState.Updates.v7_0_0.dateFields, "workspace"); + if (!hideDateDeprecation) { + // Migration scripts can be written here + const publishField = Settings.inspect(SETTING_DATE_FIELD); + const modifiedField = Settings.inspect(SETTING_MODIFIED_FIELD); - // Check for deprecation - if (publishField?.workspaceValue || - publishField?.globalValue || - publishField?.teamValue || - modifiedField?.workspaceValue || - modifiedField?.globalValue || - modifiedField?.teamValue) { - Notifications.warning(`The "${SETTING_DATE_FIELD}" and "${SETTING_MODIFIED_FIELD}" settings have been deprecated. Please use the "isPublishDate" and "isModifiedDate" datetime field properties instead.`, "See migration guide").then(value => { - if (value === "See migration guide") { - const isProd = this.isProductionMode; - commands.executeCommand("vscode.open", Uri.parse(`https://${isProd ? '' : 'beta.'}frontmatter.codes/docs/troubleshooting#publish-and-modified-date-migration`)); - } - }); + // Check for deprecation + if (publishField?.workspaceValue || + publishField?.globalValue || + publishField?.teamValue || + modifiedField?.workspaceValue || + modifiedField?.globalValue || + modifiedField?.teamValue) { + Notifications.warning(`The "${CONFIG_KEY}.${SETTING_DATE_FIELD}" and "${CONFIG_KEY}.${SETTING_MODIFIED_FIELD}" settings have been deprecated. Please use the "isPublishDate" and "isModifiedDate" datetime field properties instead.`, "Hide", "See migration guide").then(async (value) => { + if (value === "See migration guide") { + const isProd = this.isProductionMode; + commands.executeCommand("vscode.open", Uri.parse(`https://${isProd ? '' : 'beta.'}frontmatter.codes/docs/troubleshooting#publish-and-modified-date-migration`)); + await Extension.getInstance().setState(ExtensionState.Updates.v7_0_0.dateFields, true, "workspace"); + } else if (value === "Hide") { + await Extension.getInstance().setState(ExtensionState.Updates.v7_0_0.dateFields, true, "workspace"); + } + }); + } } if (major < 7) { diff --git a/src/helpers/Notifications.ts b/src/helpers/Notifications.ts index b3adff91..516ebdad 100644 --- a/src/helpers/Notifications.ts +++ b/src/helpers/Notifications.ts @@ -6,31 +6,31 @@ import { Settings } from "./SettingsHelper"; export class Notifications { - public static info(message: string, items?: any): Thenable { + public static info(message: string, ...items: any): Thenable { Logger.info(`${EXTENSION_NAME}: ${message}`, "INFO"); if (this.shouldShow("INFO")) { - return window.showInformationMessage(`${EXTENSION_NAME}: ${message}`, items); + return window.showInformationMessage(`${EXTENSION_NAME}: ${message}`, ...items); } return Promise.resolve(undefined); } - public static warning(message: string, items?: any): Thenable { + public static warning(message: string, ...items: any): Thenable { Logger.info(`${EXTENSION_NAME}: ${message}`, "WARNING"); if (this.shouldShow("WARNING")) { - return window.showWarningMessage(`${EXTENSION_NAME}: ${message}`, items); + return window.showWarningMessage(`${EXTENSION_NAME}: ${message}`, ...items); } return Promise.resolve(undefined); } - public static error(message: string, items?: any): Thenable { + public static error(message: string, ...items: any): Thenable { Logger.info(`${EXTENSION_NAME}: ${message}`, "ERROR"); if (this.shouldShow("ERROR")) { - return window.showErrorMessage(`${EXTENSION_NAME}: ${message}`, items); + return window.showErrorMessage(`${EXTENSION_NAME}: ${message}`, ...items); } return Promise.resolve(undefined);