mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-07 01:13:08 +02:00
#655 - Refresh settings
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
### ✨ New features
|
||||
|
||||
- [#650](https://github.com/estruyf/vscode-front-matter/issues/650): Added template support for [Astro Starlight](https://starlight.astro.build/)
|
||||
- [#655](https://github.com/estruyf/vscode-front-matter/issues/655): Added a new command to manually refresh the settings of the Front Matter CMS
|
||||
|
||||
### 🎨 Enhancements
|
||||
|
||||
|
||||
+11
-1
@@ -1766,6 +1766,12 @@
|
||||
"category": "Front Matter",
|
||||
"icon": "$(arrow-swap)"
|
||||
},
|
||||
{
|
||||
"command": "frontMatter.settings.refresh",
|
||||
"title": "%command.frontMatter.settings.refresh%",
|
||||
"category": "Front Matter",
|
||||
"icon": "$(refresh)"
|
||||
},
|
||||
{
|
||||
"command": "frontMatter.config.reload",
|
||||
"title": "%command.frontMatter.config.reload%",
|
||||
@@ -2360,9 +2366,13 @@
|
||||
"group": "navigation@3",
|
||||
"when": "view == frontMatter.explorer && frontMatter:project:switch:enabled"
|
||||
},
|
||||
{
|
||||
"command": "frontMatter.settings.refresh",
|
||||
"group": "navigation@4"
|
||||
},
|
||||
{
|
||||
"command": "frontMatter.dashboard",
|
||||
"group": "navigation@4",
|
||||
"group": "navigation@5",
|
||||
"when": "view == frontMatter.explorer || view == explorer"
|
||||
}
|
||||
]
|
||||
|
||||
+2
-1
@@ -241,5 +241,6 @@
|
||||
"setting.frontMatter.taxonomy.modifiedField.deprecationMessage": "Diese Einstellung ist veraltet und wird in der nächsten Hauptversion entfernt. Bitte verwenden Sie stattdessen die neuen `isModifiedDate`-Einstellungen in den Datumsfeldern Ihrer Content-Typen.",
|
||||
"setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.customType.description": "🚧: Specify the name of the custom field type to use.",
|
||||
"setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.clearEmpty.description": "🚧: Specify if the empty values should be cleared.",
|
||||
"setting.frontMatter.website.host.markdownDescription": "🚧: Specify the host URL of your website. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.website.url)"
|
||||
"setting.frontMatter.website.host.markdownDescription": "🚧: Specify the host URL of your website. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.website.url)",
|
||||
"command.frontMatter.settings.refresh": "🚧: Refresh Front Matter Settings"
|
||||
}
|
||||
+2
-1
@@ -242,5 +242,6 @@
|
||||
"setting.frontMatter.global.disabledNotifications.markdownDescription": "🚧: This is an array with the notifications types that can be disabled for Front Matter CMS. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.global.disablednotifications)",
|
||||
"setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.customType.description": "🚧: Specify the name of the custom field type to use.",
|
||||
"setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.clearEmpty.description": "🚧: Specify if the empty values should be cleared.",
|
||||
"setting.frontMatter.website.host.markdownDescription": "🚧: Specify the host URL of your website. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.website.url)"
|
||||
"setting.frontMatter.website.host.markdownDescription": "🚧: Specify the host URL of your website. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.website.url)",
|
||||
"command.frontMatter.settings.refresh": "🚧: Refresh Front Matter Settings"
|
||||
}
|
||||
+2
-1
@@ -241,5 +241,6 @@
|
||||
"setting.frontMatter.taxonomy.modifiedField.deprecationMessage": "This setting is deprecated and will be removed in the next major version. Please use the new `isModifiedDate` settings instead in your content types date fields.",
|
||||
"setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.customType.description": "Specify the name of the custom field type to use.",
|
||||
"setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.clearEmpty.description": "Specify if the empty values should be cleared.",
|
||||
"setting.frontMatter.website.host.markdownDescription": "Specify the host URL of your website. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.website.url)"
|
||||
"setting.frontMatter.website.host.markdownDescription": "Specify the host URL of your website. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.website.url)",
|
||||
"command.frontMatter.settings.refresh": "Refresh Front Matter Settings"
|
||||
}
|
||||
@@ -42,6 +42,9 @@ export const COMMAND_NAME = {
|
||||
|
||||
showOutputChannel: getCommandName('showOutputChannel'),
|
||||
|
||||
// Settings
|
||||
settingsRefresh: getCommandName('settings.refresh'),
|
||||
|
||||
// Insert dashboards
|
||||
insertMedia: getCommandName('insertMedia'),
|
||||
insertSnippet: getCommandName('insertSnippet'),
|
||||
|
||||
@@ -61,6 +61,7 @@ export class Settings {
|
||||
private static fileDeleteListener: vscode.Disposable;
|
||||
private static readConfigPromise: Promise<void> | undefined = undefined;
|
||||
private static project: Project | undefined = undefined;
|
||||
private static configDebouncer = debounceCallback();
|
||||
|
||||
public static async init() {
|
||||
await Settings.readConfig();
|
||||
@@ -94,6 +95,8 @@ export class Settings {
|
||||
commands.registerCommand(COMMAND_NAME.reloadConfig, Settings.rebindWatchers);
|
||||
}
|
||||
|
||||
commands.registerCommand(COMMAND_NAME.settingsRefresh, Settings.reloadConfig);
|
||||
|
||||
Settings.config = vscode.workspace.getConfiguration(CONFIG_KEY);
|
||||
|
||||
Settings.attachListener('settings-init', async () => {
|
||||
@@ -220,7 +223,6 @@ export class Settings {
|
||||
*/
|
||||
public static onConfigChange() {
|
||||
const projectConfig = Settings.projectConfigPath;
|
||||
const configDebouncer = debounceCallback();
|
||||
|
||||
workspace.onDidChangeConfiguration(() => {
|
||||
Settings.triggerListeners();
|
||||
@@ -246,25 +248,10 @@ export class Settings {
|
||||
);
|
||||
Settings.fileChangeWatcher.onDidChange(async () => {
|
||||
Logger.info(`Config change detected - ${projectConfig} changed`);
|
||||
configDebouncer(() => Settings.triggerListeners(), 200);
|
||||
Settings.configDebouncer(() => Settings.triggerListeners(), 200);
|
||||
});
|
||||
}
|
||||
|
||||
const reloadConfig = async (debounced: boolean = true) => {
|
||||
Logger.info(`Reloading config...`);
|
||||
if (Settings.readConfigPromise === undefined) {
|
||||
Settings.readConfigPromise = Settings.readConfig();
|
||||
}
|
||||
await Settings.readConfigPromise;
|
||||
|
||||
Logger.info(`Reloaded config...`);
|
||||
if (debounced) {
|
||||
configDebouncer(() => Settings.triggerListeners(), 200);
|
||||
} else {
|
||||
Settings.triggerListeners();
|
||||
}
|
||||
};
|
||||
|
||||
if (Settings.fileSaveListener) {
|
||||
Settings.fileSaveListener.dispose();
|
||||
}
|
||||
@@ -274,7 +261,7 @@ export class Settings {
|
||||
|
||||
if (Settings.checkProjectConfig(filename)) {
|
||||
Logger.info(`Config change detected - ${filename} saved`);
|
||||
await reloadConfig();
|
||||
await Settings.reloadConfig();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -285,7 +272,7 @@ export class Settings {
|
||||
Settings.fileDeleteListener = workspace.onDidDeleteFiles(async (e) => {
|
||||
const needCallback = e?.files.find((f) => Settings.checkProjectConfig(f.fsPath));
|
||||
if (needCallback) {
|
||||
await reloadConfig(false);
|
||||
await Settings.reloadConfig(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1034,4 +1021,23 @@ export class Settings {
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the config
|
||||
* @param debounced
|
||||
*/
|
||||
private static async reloadConfig(debounced: boolean = true) {
|
||||
Logger.info(`Reloading config...`);
|
||||
if (Settings.readConfigPromise === undefined) {
|
||||
Settings.readConfigPromise = Settings.readConfig();
|
||||
}
|
||||
await Settings.readConfigPromise;
|
||||
|
||||
Logger.info(`Reloaded config...`);
|
||||
if (debounced) {
|
||||
Settings.configDebouncer(() => Settings.triggerListeners(), 200);
|
||||
} else {
|
||||
Settings.triggerListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user