mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-18 22:28:51 -05:00
migrateSettingFromPlugin
This commit is contained in:
parent
4058737d87
commit
a52ca1f85e
2 changed files with 15 additions and 1 deletions
|
@ -247,6 +247,19 @@ export function migratePluginSetting(pluginName: string, oldSetting: string, new
|
|||
SettingsStore.markAsChanged();
|
||||
}
|
||||
|
||||
export function migrateSettingFromPlugin(newPlugin: string, newSetting: string, oldPlugin: string, oldSetting: string) {
|
||||
const newSettings = SettingsStore.plain.plugins[newPlugin];
|
||||
const oldSettings = SettingsStore.plain.plugins[oldPlugin];
|
||||
if (!oldSettings || !Object.hasOwn(oldSettings, oldSetting)) return;
|
||||
if (!newSettings || (Object.hasOwn(SettingsStore.plain.plugins[newPlugin], newSetting))) return;
|
||||
|
||||
if (Object.hasOwn(SettingsStore.plain.plugins[newPlugin], newSetting)) return;
|
||||
|
||||
SettingsStore.plain.plugins[newPlugin][newSetting] = oldSettings[oldSetting];
|
||||
delete oldSettings[oldSetting];
|
||||
SettingsStore.markAsChanged();
|
||||
}
|
||||
|
||||
export function definePluginSettings<
|
||||
Def extends SettingsDefinition,
|
||||
Checks extends SettingsChecks<Def>,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { DataStore } from "@api/index";
|
||||
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
|
||||
import { definePluginSettings, migratePluginSettings, migrateSettingFromPlugin } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { useForceUpdater } from "@utils/react";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
@ -101,6 +101,7 @@ const settings = definePluginSettings({
|
|||
},
|
||||
});
|
||||
|
||||
migrateSettingFromPlugin("RPCEditor", "replacedAppIds", "ReplaceActivityTypes", "replacedAppIds");
|
||||
migratePluginSettings("RPCEditor", "ReplaceActivityTypes");
|
||||
export default definePlugin({
|
||||
name: "RPCEditor",
|
||||
|
|
Loading…
Add table
Reference in a new issue