Skip to content

Commit

Permalink
Move clear interval until after things are setup
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman authored and TonyGiorgio committed Jun 6, 2024
1 parent 152abb0 commit 318fa6f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/state/megaStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const makeMegaStoreContext = () => {
}
},
async setup(password?: string): Promise<void> {
let interval: NodeJS.Timeout | undefined;
try {
const settings = await getSettings();
setState({ load_stage: "setup" });
Expand All @@ -179,7 +180,7 @@ export const makeMegaStoreContext = () => {
// 90 seconds to load or we bail
const start = Date.now();
const MAX_LOAD_TIME = 90000;
const interval = setInterval(() => {
interval = setInterval(() => {
console.log("Running setup", Date.now() - start);
if (Date.now() - start > MAX_LOAD_TIME) {
clearInterval(interval);
Expand Down Expand Up @@ -215,8 +216,6 @@ export const makeMegaStoreContext = () => {
nsec
);

clearInterval(interval);

if (!success) {
throw new Error("Failed to initialize mutiny wallet");
}
Expand Down Expand Up @@ -265,8 +264,15 @@ export const makeMegaStoreContext = () => {

console.log("Wallet initialized");

clearInterval(interval);

await actions.postSetup();
} catch (e) {
// clear the interval if it exists
if (interval) {
clearInterval(interval);
}

console.error(e);
if (eify(e).message === "Incorrect password entered.") {
setState({ needs_password: true });
Expand Down

0 comments on commit 318fa6f

Please sign in to comment.