mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-19 05:43:35 -05:00
Make aftersave void
This commit is contained in:
parent
7c95d3a729
commit
ebfaf54263
3 changed files with 18 additions and 4 deletions
|
@ -126,15 +126,16 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
||||||
}
|
}
|
||||||
|
|
||||||
let restartNeeded = false;
|
let restartNeeded = false;
|
||||||
if (plugin.name === "CustomSounds") restartNeeded = true;
|
|
||||||
for (const [key, value] of Object.entries(tempSettings)) {
|
for (const [key, value] of Object.entries(tempSettings)) {
|
||||||
const option = plugin.options[key];
|
const option = plugin.options[key];
|
||||||
pluginSettings[key] = value;
|
pluginSettings[key] = value;
|
||||||
option?.onChange?.(value);
|
option?.onChange?.(value);
|
||||||
if (option?.restartNeeded) restartNeeded = true;
|
if (option?.restartNeeded) restartNeeded = true;
|
||||||
}
|
}
|
||||||
|
if (plugin.afterSave) {
|
||||||
|
plugin.afterSave();
|
||||||
|
}
|
||||||
if (restartNeeded) onRestartNeeded();
|
if (restartNeeded) onRestartNeeded();
|
||||||
plugin.afterSave = true;
|
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { DataStore } from "@api/index";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs, EquicordDevs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { React } from "@webpack/common";
|
import { Alerts, React } from "@webpack/common";
|
||||||
|
|
||||||
import { SoundOverrideComponent } from "./components/SoundOverrideComponent";
|
import { SoundOverrideComponent } from "./components/SoundOverrideComponent";
|
||||||
import { makeEmptyOverride, SoundOverride, soundTypes } from "./types";
|
import { makeEmptyOverride, SoundOverride, soundTypes } from "./types";
|
||||||
|
@ -81,6 +81,19 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
findOverride,
|
findOverride,
|
||||||
isOverriden,
|
isOverriden,
|
||||||
|
afterSave() {
|
||||||
|
Alerts.show({
|
||||||
|
title: "Restart required",
|
||||||
|
body: (
|
||||||
|
<>
|
||||||
|
<p>CustomSounds requires a restart for settings to activate.</p>
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
confirmText: "Restart now",
|
||||||
|
cancelText: "Later!",
|
||||||
|
onConfirm: () => location.reload()
|
||||||
|
});
|
||||||
|
},
|
||||||
async start() {
|
async start() {
|
||||||
overrides = await DataStore.get(OVERRIDES_KEY) ?? {};
|
overrides = await DataStore.get(OVERRIDES_KEY) ?? {};
|
||||||
for (const type of soundTypes)
|
for (const type of soundTypes)
|
||||||
|
|
|
@ -121,7 +121,7 @@ export interface PluginDef {
|
||||||
* Check that this returns true after allowing a save to complete.
|
* Check that this returns true after allowing a save to complete.
|
||||||
* If a string is returned, show the error to the user.
|
* If a string is returned, show the error to the user.
|
||||||
*/
|
*/
|
||||||
afterSave?: boolean;
|
afterSave?(): void;
|
||||||
/**
|
/**
|
||||||
* Allows you to specify a custom Component that will be rendered in your
|
* Allows you to specify a custom Component that will be rendered in your
|
||||||
* plugin's settings page
|
* plugin's settings page
|
||||||
|
|
Loading…
Reference in a new issue