Settings: Add MigratePluginToSetting
This commit is contained in:
parent
265b57758d
commit
b3ed350494
3 changed files with 19 additions and 16 deletions
|
|
@ -225,6 +225,20 @@ export function useSettings(paths?: UseSettings<Settings>[]) {
|
|||
return SettingsStore.store;
|
||||
}
|
||||
|
||||
export function migratePluginToSetting(newName: string, oldName: string, settingName: string) {
|
||||
const { plugins } = SettingsStore.plain;
|
||||
const newPlugin = plugins[newName];
|
||||
const oldPlugin = plugins[oldName];
|
||||
|
||||
if (!newPlugin || !oldPlugin) return;
|
||||
|
||||
if (oldPlugin?.enabled) {
|
||||
newPlugin[settingName] = true;
|
||||
oldPlugin.enabled = false;
|
||||
SettingsStore.markAsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
export function migratePluginSettings(name: string, ...oldNames: string[]) {
|
||||
const { plugins } = SettingsStore.plain;
|
||||
if (name in plugins) return;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
import "./styles.css";
|
||||
|
||||
import { showNotification } from "@api/Notifications";
|
||||
import { definePluginSettings, Settings } from "@api/Settings";
|
||||
import { definePluginSettings, migratePluginToSetting } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
|
|
@ -19,6 +19,7 @@ import { Menu, Toasts } from "@webpack/common";
|
|||
|
||||
import { ContactsList } from "./types";
|
||||
|
||||
migratePluginToSetting("ExportMessages", "ExportContacts", "exportContacts");
|
||||
const settings = definePluginSettings({
|
||||
openFileAfterExport: {
|
||||
type: OptionType.BOOLEAN,
|
||||
|
|
@ -155,12 +156,6 @@ export default definePlugin({
|
|||
}
|
||||
}
|
||||
],
|
||||
start() {
|
||||
if (Settings.plugins?.ExportContacts?.enabled) {
|
||||
Settings.plugins.ExportContacts.enabled = false;
|
||||
settings.store.exportContacts = true;
|
||||
}
|
||||
},
|
||||
getContacts(contacts: ContactsList[]) {
|
||||
this.contactList = {
|
||||
friendsAdded: [...getUsernames(contacts, 1)],
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import "./styles.css";
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { migratePluginToSetting } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
|
@ -31,6 +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");
|
||||
export default definePlugin({
|
||||
name: "MusicControls",
|
||||
description: "Music Controls and Lyrics for multiple services ",
|
||||
|
|
@ -119,14 +121,6 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
async start() {
|
||||
if (Settings.plugins?.SpotifyControls?.enabled) {
|
||||
settings.store.showSpotifyControls = true;
|
||||
Settings.plugins.SpotifyControls.enabled = false;
|
||||
}
|
||||
if (Settings.plugins?.SpotifyLyrics?.enabled) {
|
||||
settings.store.showSpotifyLyrics = true;
|
||||
Settings.plugins.SpotifyLyrics.enabled = false;
|
||||
}
|
||||
await migrateOldLyrics();
|
||||
toggleHoverControls(settings.store.hoverControls);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue