From 21ded874a3e94415639ee14b3e8716d894e3456a Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Mon, 27 Jan 2025 20:47:27 -0300 Subject: [PATCH] Settings API: Add utility to migrate a setting --- src/api/Settings.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/Settings.ts b/src/api/Settings.ts index c99d030d0..8c05d9bb3 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -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,