From 061e40259bae010ef9ab9dd219eb5f05bc89834b Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 11 May 2023 16:40:19 -0500 Subject: [PATCH] stop mutiny_wallet on unload --- src/state/megaStore.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/state/megaStore.tsx b/src/state/megaStore.tsx index d71884b..e9b4d61 100644 --- a/src/state/megaStore.tsx +++ b/src/state/megaStore.tsx @@ -138,6 +138,13 @@ export const Provider: ParentComponent = (props) => { if (state.user_status === "approved" && !state.mutiny_wallet && !state.deleting) { console.log("running setup node manager...") actions.setupMutinyWallet().then(() => console.log("node manager setup done")) + + // Setup an event listener to stop the mutiny wallet when the page unloads + window.onunload = async (e) => { + console.log("stopping mutiny_wallet") + await state.mutiny_wallet?.stop(); + console.log("mutiny_wallet stopped") + } } }) })