From 8e8449b1e2ec29289b731e6d8f2d976d252c0873 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sat, 13 Sep 2025 01:22:07 -0400 Subject: [PATCH] PluginTab: Make Reset Same Component There is 100% a better way --- .../settings/tabs/plugins/PluginModal.tsx | 26 ++++-- .../settings/tabs/plugins/index.tsx | 85 ++----------------- .../settings/tabs/plugins/styles.css | 10 ++- 3 files changed, 33 insertions(+), 88 deletions(-) diff --git a/src/components/settings/tabs/plugins/PluginModal.tsx b/src/components/settings/tabs/plugins/PluginModal.tsx index 8175ecf6f..59de61aa2 100644 --- a/src/components/settings/tabs/plugins/PluginModal.tsx +++ b/src/components/settings/tabs/plugins/PluginModal.tsx @@ -295,8 +295,17 @@ function resetSettings(plugin: Plugin, warningModalProps?: ModalProps, pluginMod pluginModalProps?.onClose(); } -export function openWarningModal(plugin: Plugin, pluginModalProps: ModalProps, onRestartNeeded?: (pluginName: string) => void) { - if (Settings.ignoreResetWarning) return resetSettings(plugin, pluginModalProps, pluginModalProps, onRestartNeeded); +export function openWarningModal(plugin?: Plugin | null, pluginModalProps?: ModalProps | null, onRestartNeeded?: (pluginName: string) => void, isPlugin = true, enabledPlugins?: number | null, reset?: any) { + if (Settings.ignoreResetWarning && isPlugin) { + if (plugin && pluginModalProps) return resetSettings(plugin, pluginModalProps, pluginModalProps, onRestartNeeded); + return; + } else if (Settings.ignoreResetWarning && !isPlugin) { + return reset(); + } + + const text = isPlugin + ? `You are about to reset all settings for ${plugin?.name} to their default values.` + : `You are about to disable ${enabledPlugins} plugins!`; openModal(warningModalProps => ( - You are about to reset all settings for {plugin.name} to their default values. + {text} THIS ACTION IS IRREVERSIBLE! @@ -324,8 +333,8 @@ export function openWarningModal(plugin: Plugin, pluginModalProps: ModalProps, o - - + + - {!Settings.ignoreResetWarning && ( - - )} - - - - - - - )); - } - // Code directly taken from supportHelper.tsx const isApiPlugin = (plugin: string) => plugin.endsWith("API") || Plugins[plugin].required; @@ -402,7 +331,7 @@ export default function PluginSettings() { return ( - +