mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-13 16:43:04 -04:00
Less confusing plugin names (bulk plugin rename) (#214)
Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
This commit is contained in:
parent
a96f8a89f3
commit
82e444e196
17 changed files with 94 additions and 45 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue