aboutsummaryrefslogtreecommitdiff
path: root/src/api/settings.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/settings.ts')
-rw-r--r--src/api/settings.ts20
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;
+ }
+ }
+}