aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2023-01-23 22:43:25 +0100
committerVendicated <vendicated@riseup.net>2023-01-23 22:43:25 +0100
commit25d32ce2922f276f1a7f67c8d3be978a8d360042 (patch)
tree0e4df51523da335ba4735755b12898dfed3ce16e /src/components
parentcb4c50842f36a1d23a18618741b787dc3dafdc68 (diff)
downloadVencord-25d32ce2922f276f1a7f67c8d3be978a8d360042.tar.gz
Vencord-25d32ce2922f276f1a7f67c8d3be978a8d360042.tar.bz2
Vencord-25d32ce2922f276f1a7f67c8d3be978a8d360042.zip
Settings: Fix plugin switch state not updating (fixes #209)
Diffstat (limited to 'src/components')
-rw-r--r--src/components/PluginSettings/index.tsx15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx
index 58058b1..4b6abdd 100644
--- a/src/components/PluginSettings/index.tsx
+++ b/src/components/PluginSettings/index.tsx
@@ -92,12 +92,9 @@ interface PluginCardProps extends React.HTMLProps<HTMLDivElement> {
}
function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLeave, isNew }: PluginCardProps) {
- const settings = useSettings();
- const pluginSettings = settings.plugins[plugin.name];
+ const settings = useSettings([`plugins.${plugin.name}`]).plugins[plugin.name];
- function isEnabled() {
- return pluginSettings?.enabled || plugin.started;
- }
+ const isEnabled = () => settings.enabled ?? false;
function openModal() {
openModalLazy(async () => {
@@ -119,7 +116,7 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe
return;
} else if (restartNeeded) {
// If any dependencies have patches, don't start the plugin yet.
- pluginSettings.enabled = true;
+ settings.enabled = true;
onRestartNeeded(plugin.name);
return;
}
@@ -127,14 +124,14 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe
// if the plugin has patches, dont use stopPlugin/startPlugin. Wait for restart to apply changes.
if (plugin.patches) {
- pluginSettings.enabled = !wasEnabled;
+ settings.enabled = !wasEnabled;
onRestartNeeded(plugin.name);
return;
}
// If the plugin is enabled, but hasn't been started, then we can just toggle it off.
if (wasEnabled && !plugin.started) {
- pluginSettings.enabled = !wasEnabled;
+ settings.enabled = !wasEnabled;
return;
}
@@ -147,7 +144,7 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe
return;
}
- pluginSettings.enabled = !wasEnabled;
+ settings.enabled = !wasEnabled;
}
return (