Settings API: Add utility to migrate a setting
This commit is contained in:
parent
ea1e96185b
commit
21ded874a3
1 changed files with 13 additions and 0 deletions
|
@ -220,6 +220,19 @@ export function migratePluginSettings(name: string, ...oldNames: string[]) {
|
|||
}
|
||||
}
|
||||
|
||||
export function migratePluginSetting(pluginName: string, oldSetting: string, newSetting: string) {
|
||||
const { plugins } = SettingsStore.plain;
|
||||
|
||||
if (
|
||||
plugins[pluginName][newSetting] != null ||
|
||||
plugins[pluginName][oldSetting] == null
|
||||
) return;
|
||||
|
||||
plugins[pluginName][newSetting] = plugins[pluginName][oldSetting];
|
||||
delete plugins[pluginName][oldSetting];
|
||||
SettingsStore.markAsChanged();
|
||||
}
|
||||
|
||||
export function definePluginSettings<
|
||||
Def extends SettingsDefinition,
|
||||
Checks extends SettingsChecks<Def>,
|
||||
|
|
Loading…
Reference in a new issue