Settings API: Add utility to migrate a setting

This commit is contained in:
Nuckyz 2025-01-27 20:47:27 -03:00
parent ea1e96185b
commit 21ded874a3
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -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>,