From 42d8211871d84e2650f7c762c66e2ee2e6c58968 Mon Sep 17 00:00:00 2001 From: V Date: Tue, 13 Jun 2023 02:29:15 +0200 Subject: [PATCH] Fix disabling plugins whose stop() errors --- src/components/PluginSettings/index.tsx | 8 +++++--- src/plugins/arRPC.web.tsx | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index e1b36ef25..655eeefe9 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -138,11 +138,13 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe } const result = wasEnabled ? stopPlugin(plugin) : startPlugin(plugin); - const action = wasEnabled ? "stop" : "start"; if (!result) { - logger.error(`Failed to ${action} plugin ${plugin.name}`); - showErrorToast(`Failed to ${action} plugin: ${plugin.name}`); + settings.enabled = false; + + const msg = `Error while ${wasEnabled ? "stopping" : "starting"} plugin ${plugin.name}`; + logger.error(msg); + showErrorToast(msg); return; } diff --git a/src/plugins/arRPC.web.tsx b/src/plugins/arRPC.web.tsx index 9a16c6409..f0d484141 100644 --- a/src/plugins/arRPC.web.tsx +++ b/src/plugins/arRPC.web.tsx @@ -104,6 +104,6 @@ export default definePlugin({ stop() { FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", activity: null }); // clear status - ws.close(); // close WebSocket + ws?.close(); // close WebSocket } });