Skip to content

Commit

Permalink
last try
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenmarcus committed Aug 22, 2023
1 parent 3a3d802 commit 89bf9af
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions packages/wallet/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ export class MintbaseWallet {
justify-content: center;
align-items: center;
height: 100vh;
position:fixed
top:0px
left:0px
width:100vw
background:#fff
position:fixed;
top:0px;
left:0px;
width:100vw;
background:#fff;
}
.lds-ellipsis {
Expand Down Expand Up @@ -353,6 +353,8 @@ export class MintbaseWallet {
this.injectKeyframeAnimations();
this.showLoadingAnimation();



function forceRefresh() {
// Append a timestamp or random value as a query parameter to the URL
const currentUrl = new URL(window.location.href);
Expand All @@ -362,26 +364,18 @@ export class MintbaseWallet {
window.location.href = currentUrl.toString();
}

const currentUrl = new URL(window.location.href);
currentUrl.searchParams.delete('account_id');
currentUrl.searchParams.delete('public_key');

window.history.replaceState({}, document.title, currentUrl.toString());

// Listen for changes to the localStorage value
const storageEventListener = (event: StorageEvent) => {
if (event.key === 'mintbasewallet:account-data') {
window.removeEventListener('storage', storageEventListener);
this.hideLoadingAnimation();
if (!this.reloaded) {
this.reloaded = true;
forceRefresh();
}
}
};
// Check if account data is already set in localStorage
const accountData = window.localStorage.getItem('mintbasewallet:account-data');
if (accountData && !this.reloaded) {
this.reloaded = true; // Set the flag

this.hideLoadingAnimation();


forceRefresh(); // Trigger a single forced refresh
}

// Add the storage event listener
window.addEventListener('storage', storageEventListener);

}

private reloaded = false;
Expand Down

0 comments on commit 89bf9af

Please sign in to comment.