aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/devCompanion.dev.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/devCompanion.dev.tsx')
-rw-r--r--src/plugins/devCompanion.dev.tsx33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/plugins/devCompanion.dev.tsx b/src/plugins/devCompanion.dev.tsx
index cea71e0..c3d4d6a 100644
--- a/src/plugins/devCompanion.dev.tsx
+++ b/src/plugins/devCompanion.dev.tsx
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import { addContextMenuPatch } from "@api/ContextMenu";
+import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
import { showNotification } from "@api/Notifications";
import { Devs } from "@utils/constants";
import Logger from "@utils/Logger";
@@ -221,6 +221,21 @@ function initWs(isManual = false) {
});
}
+const contextMenuPatch: NavContextMenuPatchCallback = kids => {
+ if (kids.some(k => k?.props?.id === NAV_ID)) return;
+
+ kids.unshift(
+ <Menu.MenuItem
+ id={NAV_ID}
+ label="Reconnect Dev Companion"
+ action={() => {
+ socket?.close(1000, "Reconnecting");
+ initWs(true);
+ }}
+ />
+ );
+};
+
export default definePlugin({
name: "DevCompanion",
description: "Dev Companion Plugin",
@@ -229,24 +244,12 @@ export default definePlugin({
start() {
initWs();
- addContextMenuPatch("user-settings-cog", kids => {
- if (kids.some(k => k?.props?.id === NAV_ID)) return;
-
- kids.unshift(
- <Menu.MenuItem
- id={NAV_ID}
- label="Reconnect Dev Companion"
- action={() => {
- socket?.close(1000, "Reconnecting");
- initWs(true);
- }}
- />
- );
- });
+ addContextMenuPatch("user-settings-cog", contextMenuPatch);
},
stop() {
socket?.close(1000, "Plugin Stopped");
socket = void 0;
+ removeContextMenuPatch("user-settings-cog", contextMenuPatch);
}
});