mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-07-13 13:21:03 +02:00
async updates for settings
This commit is contained in:
@@ -37,7 +37,7 @@ categories: []
|
|||||||
await Settings.createTeamSettings();
|
await Settings.createTeamSettings();
|
||||||
|
|
||||||
// Add the default content type
|
// Add the default content type
|
||||||
Settings.update(SETTING_TAXONOMY_CONTENT_TYPES, [DEFAULT_CONTENT_TYPE], true);
|
await Settings.update(SETTING_TAXONOMY_CONTENT_TYPES, [DEFAULT_CONTENT_TYPE], true);
|
||||||
|
|
||||||
if (sampleTemplate !== undefined) {
|
if (sampleTemplate !== undefined) {
|
||||||
await Project.createSampleTemplate();
|
await Project.createSampleTemplate();
|
||||||
|
|||||||
@@ -163,10 +163,10 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
|
|||||||
];
|
];
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (settings.crntFramework) {
|
if (settings.crntFramework || settings.framework?.name) {
|
||||||
setFramework(settings.crntFramework);
|
setFramework(settings.crntFramework || settings.framework?.name || null);
|
||||||
}
|
}
|
||||||
}, [settings.crntFramework]);
|
}, [settings.crntFramework, settings.framework]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav aria-label="Progress">
|
<nav aria-label="Progress">
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ export class ContentType {
|
|||||||
contentTypes.push(newContentType);
|
contentTypes.push(newContentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.update(SETTING_TAXONOMY_CONTENT_TYPES, contentTypes, true);
|
await Settings.update(SETTING_TAXONOMY_CONTENT_TYPES, contentTypes, true);
|
||||||
|
|
||||||
const configPath = Settings.projectConfigPath;
|
const configPath = Settings.projectConfigPath;
|
||||||
const notificationAction = await Notifications.info(`Content type ${contentTypeName} has been ${overrideBool ? `updated` : `generated`}.`, configPath && await existsAsync(configPath) ? `Open settings` : undefined);
|
const notificationAction = await Notifications.info(`Content type ${contentTypeName} has been ${overrideBool ? `updated` : `generated`}.`, configPath && await existsAsync(configPath) ? `Open settings` : undefined);
|
||||||
@@ -228,7 +228,7 @@ export class ContentType {
|
|||||||
const index = contentTypes.findIndex(ct => ct.name === contentType.name);
|
const index = contentTypes.findIndex(ct => ct.name === contentType.name);
|
||||||
contentTypes[index].fields = updatedFields;
|
contentTypes[index].fields = updatedFields;
|
||||||
|
|
||||||
Settings.update(SETTING_TAXONOMY_CONTENT_TYPES, contentTypes, true);
|
await Settings.update(SETTING_TAXONOMY_CONTENT_TYPES, contentTypes, true);
|
||||||
|
|
||||||
const configPath = Settings.projectConfigPath;
|
const configPath = Settings.projectConfigPath;
|
||||||
const notificationAction = await Notifications.info(`Content type ${contentType.name} has been updated.`, configPath && await existsAsync(configPath) ? `Open settings` : undefined);
|
const notificationAction = await Notifications.info(`Content type ${contentType.name} has been updated.`, configPath && await existsAsync(configPath) ? `Open settings` : undefined);
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ export class Extension {
|
|||||||
ignoreFocusOut: true
|
ignoreFocusOut: true
|
||||||
});
|
});
|
||||||
|
|
||||||
Settings.update(SETTING_TEMPLATES_ENABLED, answer?.toLocaleLowerCase() === "yes", true);
|
await Settings.update(SETTING_TEMPLATES_ENABLED, answer?.toLocaleLowerCase() === "yes", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,9 @@ export class Settings {
|
|||||||
const localConfig = await readFileAsync(fmConfig, 'utf8');
|
const localConfig = await readFileAsync(fmConfig, 'utf8');
|
||||||
Settings.globalConfig = jsoncParser.parse(localConfig);
|
Settings.globalConfig = jsoncParser.parse(localConfig);
|
||||||
Settings.globalConfig[`${CONFIG_KEY}.${name}`] = value;
|
Settings.globalConfig[`${CONFIG_KEY}.${name}`] = value;
|
||||||
await writeFileAsync(fmConfig, JSON.stringify(Settings.globalConfig, null, 2), 'utf8');
|
|
||||||
|
const content = JSON.stringify(Settings.globalConfig, null, 2);
|
||||||
|
await writeFileAsync(fmConfig, content, 'utf8');
|
||||||
|
|
||||||
const workspaceSettingValue = Settings.hasWorkspaceSettings<ContentType[]>(name);
|
const workspaceSettingValue = Settings.hasWorkspaceSettings<ContentType[]>(name);
|
||||||
if (workspaceSettingValue) {
|
if (workspaceSettingValue) {
|
||||||
|
|||||||
@@ -60,17 +60,17 @@ export class SettingsListener extends BaseListener {
|
|||||||
* @param frameworkId
|
* @param frameworkId
|
||||||
*/
|
*/
|
||||||
public static async setFramework(frameworkId: string | null) {
|
public static async setFramework(frameworkId: string | null) {
|
||||||
Settings.update(SETTING_FRAMEWORK_ID, frameworkId, true);
|
await Settings.update(SETTING_FRAMEWORK_ID, frameworkId, true);
|
||||||
|
|
||||||
if (frameworkId) {
|
if (frameworkId) {
|
||||||
const allFrameworks = FrameworkDetector.getAll();
|
const allFrameworks = FrameworkDetector.getAll();
|
||||||
const framework = allFrameworks.find((f: Framework) => f.name === frameworkId);
|
const framework = allFrameworks.find((f: Framework) => f.name === frameworkId);
|
||||||
if (framework) {
|
if (framework) {
|
||||||
Settings.update(SETTING_CONTENT_STATIC_FOLDER, framework.static, true);
|
await Settings.update(SETTING_CONTENT_STATIC_FOLDER, framework.static, true);
|
||||||
|
|
||||||
await FrameworkDetector.checkDefaultSettings(framework);
|
await FrameworkDetector.checkDefaultSettings(framework);
|
||||||
} else {
|
} else {
|
||||||
Settings.update(SETTING_CONTENT_STATIC_FOLDER, "", true);
|
await Settings.update(SETTING_CONTENT_STATIC_FOLDER, "", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user