From 666db392828cb10a778b089538ac58f199cfbf6e Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 5 Jun 2024 15:07:45 -0500 Subject: [PATCH] Move persistent storage init --- src/state/megaStore.tsx | 20 ++++++++++++++++++++ src/workers/walletWorker.ts | 16 ---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/state/megaStore.tsx b/src/state/megaStore.tsx index a6b7b234..f40e6eb5 100644 --- a/src/state/megaStore.tsx +++ b/src/state/megaStore.tsx @@ -207,6 +207,26 @@ export const makeMegaStoreContext = () => { console.log("No nsec stored"); } + // https://developer.mozilla.org/en-US/docs/Web/API/Storage_API + // Ask the browser to not clear storage + if (navigator.storage && navigator.storage.persist) { + navigator.storage.persist().then((persistent) => { + if (persistent) { + console.log( + "Storage will not be cleared except by explicit user action" + ); + } else { + console.log( + "Storage may be cleared by the UA under storage pressure." + ); + } + }); + } else { + console.warn( + "Persistent storage not supported, storage may be cleared by the UA under storage pressure." + ); + } + const success = await sw.setupMutinyWallet( settings, password, diff --git a/src/workers/walletWorker.ts b/src/workers/walletWorker.ts index abd79155..8e9e5481 100644 --- a/src/workers/walletWorker.ts +++ b/src/workers/walletWorker.ts @@ -97,22 +97,6 @@ export async function setupMutinyWallet( ): Promise { console.log("Starting setup..."); - // https://developer.mozilla.org/en-US/docs/Web/API/Storage_API - // Ask the browser to not clear storage - if (navigator.storage && navigator.storage.persist) { - navigator.storage.persist().then((persistent) => { - if (persistent) { - console.log( - "Storage will not be cleared except by explicit user action" - ); - } else { - console.log( - "Storage may be cleared by the UA under storage pressure." - ); - } - }); - } - const { network, proxy,