diff options
author | Ven <vendicated@riseup.net> | 2022-11-14 18:05:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-14 18:05:41 +0100 |
commit | 82e444e19635a72d2e1c4d043840bdfd358fa120 (patch) | |
tree | 85e4bc94fb6c9a7bebc3a56e311fdf967aeeb2d5 /src/api/settings.ts | |
parent | a96f8a89f36ccb980334da2274385373aa3ffb24 (diff) | |
download | Vencord-82e444e19635a72d2e1c4d043840bdfd358fa120.tar.gz Vencord-82e444e19635a72d2e1c4d043840bdfd358fa120.tar.bz2 Vencord-82e444e19635a72d2e1c4d043840bdfd358fa120.zip |
Less confusing plugin names (bulk plugin rename) (#214)
Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
Diffstat (limited to 'src/api/settings.ts')
-rw-r--r-- | src/api/settings.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/api/settings.ts b/src/api/settings.ts index 9e518c6..dd8692a 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -19,10 +19,12 @@ import plugins from "~plugins"; import IpcEvents from "../utils/IpcEvents"; +import Logger from "../utils/Logger"; import { mergeDefaults } from "../utils/misc"; import { OptionType } from "../utils/types"; import { React } from "../webpack/common"; +const logger = new Logger("Settings"); export interface Settings { notifyAboutUpdates: boolean; useQuickCss: boolean; @@ -169,3 +171,21 @@ export function addSettingsListener(path: string, onUpdate: (newValue: any, path (onUpdate as SubscriptionCallback)._path = path; subscriptions.add(onUpdate); } + +export function migratePluginSettings(name: string, ...oldNames: string[]) { + const { plugins } = settings; + if (name in plugins) return; + + for (const oldName of oldNames) { + if (oldName in plugins) { + logger.info(`Migrating settings from old name ${oldName} to ${name}`); + plugins[name] = plugins[oldName]; + delete plugins[oldName]; + VencordNative.ipc.invoke( + IpcEvents.SET_SETTINGS, + JSON.stringify(settings, null, 4) + ); + break; + } + } +} |