Skip to content

Commit

Permalink
Merge pull request #93 from getamis/ASL-5124/add-phone-field-in-qubic…
Browse files Browse the repository at this point in the history
…-user-2

[ASL-5124] add phone field in qubic user 2
  • Loading branch information
roadmanfong authored Apr 1, 2024
2 parents d5217a9 + 3489c98 commit c38fd85
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/core/src/QubicConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class QubicConnect {
public marketRequestGraphql: SdkRequestGraphql;

private readonly shouldAutoLoginInWalletIab: boolean = true;
private isUserReady = false;
constructor(config: QubicConnectConfig) {
const {
name,
Expand Down Expand Up @@ -172,13 +173,18 @@ export class QubicConnect {
}

this.handleRedirectResult();
this.hydrateUser();
this.onAuthStateChanged(QubicConnect.persistUser);
initGaTrack(this.config.trackGaSettings);
this.hydrateUser()
.then(() => {
this.onAuthStateChanged(QubicConnect.persistUser);

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

private static persistUser(user: WalletUser | null) {
Expand Down Expand Up @@ -454,9 +460,8 @@ export class QubicConnect {
// get result immediately when bind this event
// if everything is ready
if (
this.user ||
typeof this.cachedRedirectResult !== 'undefined' ||
typeof this.cachedRedirectError !== 'undefined'
this.isUserReady &&
(this.user || typeof this.cachedRedirectResult !== 'undefined' || typeof this.cachedRedirectError !== 'undefined')
) {
callback(this.user, this.cachedRedirectError);
}
Expand Down

0 comments on commit c38fd85

Please sign in to comment.