Skip to content

Commit

Permalink
* show hydrate failed error
Browse files Browse the repository at this point in the history
* remove catch error when use hydrateUser
  • Loading branch information
roadmanfong committed Apr 2, 2024
1 parent 26c7364 commit 25a9aea
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions packages/core/src/QubicConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,17 @@ export class QubicConnect {
// when state changed, persist user
this.onAuthStateChanged(QubicConnect.persistUser);
// hydrateUser will trigger handleLogin/handleLogout
this.hydrateUser()
.then(hasSavedUser => {
this.isUserReady = true;
// no stored user and no redirect result or error
if (!hasSavedUser && !this.hasRedirectResult) {
this.handleLogout(null);
}
this.hydrateUser().then(hasSavedUser => {
this.isUserReady = true;
// no stored user and no redirect result or error
if (!hasSavedUser && !this.hasRedirectResult) {
this.handleLogout(null);
}

if (!this.user && this.shouldAutoLoginInWalletIab) {
this.loginWithWallet(window.ethereum?.isQubic ? 'qubic' : 'metamask');
}
})
.catch(() => {
this.isUserReady = true;
});
if (!this.user && this.shouldAutoLoginInWalletIab) {
this.loginWithWallet(window.ethereum?.isQubic ? 'qubic' : 'metamask');
}
});
}

private static persistUser(user: WalletUser | null) {
Expand Down Expand Up @@ -237,7 +233,8 @@ export class QubicConnect {
return true;
} catch (error) {
// ignore error
console.warn('can not recover user from localStorage');
console.warn('hydrate user failed');
console.warn(error);
}
return false;
}
Expand Down

0 comments on commit 25a9aea

Please sign in to comment.