feat(settings): disable warning forever (#58)

* add disable warning forever for thororen

* Update PluginModal.tsx

* Update index.tsx
This commit is contained in:
Creation's 2024-10-15 13:03:48 -04:00 committed by GitHub
parent 5e39370fac
commit b6a0659965
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 82 additions and 41 deletions

View file

@ -328,6 +328,46 @@ export default function PluginSettings() {
}
}
function resetCheckAndDo() {
let restartNeeded = false;
for (const plugin of enabledPlugins) {
const pluginSettings = settings.plugins[plugin];
if (Plugins[plugin].patches?.length) {
pluginSettings.enabled = false;
changes.handleChange(plugin);
restartNeeded = true;
continue;
}
const result = stopPlugin(Plugins[plugin]);
if (!result) {
logger.error(`Error while stopping plugin ${plugin}`);
showErrorToast(`Error while stopping plugin ${plugin}`);
continue;
}
pluginSettings.enabled = false;
}
if (restartNeeded) {
Alerts.show({
title: "Restart Required",
body: (
<>
<p style={{ textAlign: "center" }}>Some plugins require a restart to fully disable.</p>
<p style={{ textAlign: "center" }}>Would you like to restart now?</p>
</>
),
confirmText: "Restart Now",
cancelText: "Later",
onConfirm: () => location.reload()
});
}
}
// Code directly taken from supportHelper.tsx
const isApiPlugin = (plugin: string) => plugin.endsWith("API") || Plugins[plugin].required;
@ -391,10 +431,12 @@ export default function PluginSettings() {
size={Button.Sizes.SMALL}
style={{ backgroundColor: "var(--button-danger-background)", margin: "20px 0" }}
onClick={() => {
if (Settings.ignoreResetWarning) return resetCheckAndDo();
return Alerts.show({
title: "Disable All Plugins",
body: (
<>
<div style={{ textAlign: "center" }}>
<img
src="https://media.tenor.com/Y6DXKZiBCs8AAAAi/stavario-josefbenes.gif"
alt="Warning"
@ -406,48 +448,27 @@ export default function PluginSettings() {
<p style={{ fontSize: "1rem" }}>
Are you absolutely sure you want to proceed? You can always enable them back later.
</p>
</>
{!Settings.ignoreResetWarning && (
<Button style={{
fontSize: "0.8rem",
backgroundColor: "transparent",
color: "red",
cursor: "pointer",
margin: "0 auto",
width: "fit-content",
textDecoration: "underline"
}} onClick={() => {
Settings.ignoreResetWarning = true;
}}>
Disable this warning forever
</Button>
)}
</div>
),
confirmText: "Disable All",
cancelText: "Cancel",
onConfirm: () => {
let restartNeeded = false;
for (const plugin of enabledPlugins) {
const pluginSettings = settings.plugins[plugin];
if (Plugins[plugin].patches?.length) {
pluginSettings.enabled = false;
changes.handleChange(plugin);
restartNeeded = true;
continue;
}
const result = stopPlugin(Plugins[plugin]);
if (!result) {
logger.error(`Error while stopping plugin ${plugin}`);
showErrorToast(`Error while stopping plugin ${plugin}`);
continue;
}
pluginSettings.enabled = false;
}
if (restartNeeded) {
Alerts.show({
title: "Restart Required",
body: (
<>
<p>Some plugins require a restart to fully disable.</p>
<p>Would you like to restart now?</p>
</>
),
confirmText: "Restart Now",
cancelText: "Later",
onConfirm: () => location.reload()
});
}
resetCheckAndDo();
}
});
}}
@ -456,7 +477,6 @@ export default function PluginSettings() {
</Button>
)}
{plugins.length || requiredPlugins.length
? (
<div className={cl("grid")}>