migratePluginToSetting to migratePluginToSettings

This commit is contained in:
thororen1234 2025-12-24 16:04:10 -05:00
parent 607faae32f
commit 9905fc5a50
No known key found for this signature in database
4 changed files with 18 additions and 12 deletions

View file

@ -251,7 +251,7 @@ export function useSettings(paths?: UseSettings<Settings>[]) {
return SettingsStore.store;
}
export function migratePluginToSetting(newName: string, oldName: string, settingName: string) {
export function migratePluginToSettings(newName: string, oldName: string, ...settingNames: string[]) {
const { plugins } = SettingsStore.plain;
const newPlugin = plugins[newName];
const oldPlugin = plugins[oldName];
@ -259,10 +259,14 @@ export function migratePluginToSetting(newName: string, oldName: string, setting
if (!newPlugin || !oldPlugin) return;
if (oldPlugin?.enabled) {
newPlugin[settingName] = true;
oldPlugin.enabled = false;
if (!newPlugin?.enabled) newPlugin.enabled = true;
SettingsStore.markAsChanged();
for (const settingName of settingNames) {
logger.info(`Migrating plugin to setting from old name ${oldName} to ${newName}`);
oldPlugin.enabled = false;
newPlugin[settingName] = true;
if (!newPlugin?.enabled) newPlugin.enabled = true;
delete plugins[oldName];
SettingsStore.markAsChanged();
}
}
}
@ -287,6 +291,7 @@ export function migratePluginSetting(pluginName: string, newSetting: string, old
if (!Object.hasOwn(settings, oldSetting) || Object.hasOwn(settings, newSetting)) return;
logger.info(`Migrating plugin setting from ${oldSetting} to ${newSetting} on ${pluginName}`);
settings[newSetting] = settings[oldSetting];
delete settings[oldSetting];
SettingsStore.markAsChanged();
@ -300,6 +305,7 @@ export function migrateSettingFromPlugin(newPlugin: string, newSetting: string,
if (Object.hasOwn(newSettings, newSetting)) return;
logger.info(`Migrating plugin setting from ${oldSetting} on ${oldPlugin} to ${newSetting} on ${newPlugin}`);
newSettings[newSetting] = oldSettings[oldSetting];
delete oldSettings[oldSetting];
SettingsStore.markAsChanged();

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings, migratePluginToSetting } from "@api/Settings";
import { definePluginSettings, migratePluginToSettings } from "@api/Settings";
import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
@ -47,7 +47,7 @@ const settings = definePluginSettings({
}
});
migratePluginToSetting("BetterUserArea", "CleanUserArea", "removeNameplate");
migratePluginToSettings("BetterUserArea", "CleanUserArea", "removeNameplate");
export default definePlugin({
name: "BetterUserArea",

View file

@ -7,7 +7,7 @@
import "./styles.css";
import { showNotification } from "@api/Notifications";
import { definePluginSettings, migratePluginToSetting } from "@api/Settings";
import { definePluginSettings, migratePluginToSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { copyToClipboard } from "@utils/clipboard";
import { EquicordDevs } from "@utils/constants";
@ -19,7 +19,7 @@ import { Menu, Toasts } from "@webpack/common";
import { ContactsList } from "./types";
migratePluginToSetting("ExportMessages", "ExportContacts", "exportContacts");
migratePluginToSettings("ExportMessages", "ExportContacts", "exportContacts");
const settings = definePluginSettings({
openFileAfterExport: {
type: OptionType.BOOLEAN,

View file

@ -18,7 +18,7 @@
import "./styles.css";
import { migratePluginToSetting } from "@api/Settings";
import { migratePluginToSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
@ -31,8 +31,8 @@ import { TidalLyrics } from "./tidal/lyrics/components/lyrics";
import { TidalPlayer } from "./tidal/TidalPlayer";
import { YtmPlayer } from "./youtubeMusic/PlayerComponent";
migratePluginToSetting("MusicControls", "SpotifyControls", "showSpotifyControls");
migratePluginToSetting("MusicControls", "SpotifyLyrics", "showSpotifyLyrics");
migratePluginToSettings("MusicControls", "SpotifyControls", "showSpotifyControls");
migratePluginToSettings("MusicControls", "SpotifyLyrics", "showSpotifyLyrics");
export default definePlugin({
name: "MusicControls",
description: "Music Controls and Lyrics for multiple services ",