Skip to content

Commit

Permalink
🐛 fix: connect popup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rustin01 committed Aug 26, 2024
1 parent 5273eec commit bb09e90
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions packages/sdk/src/lib/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ export class HibitIdWallet {
}

try {
if (this._hasSession) {
this.showIframe()
}
this.showIframe(!this._hasSession)
this._connectPromise = new BridgePromise<WalletAccount | null>()
this._rpc!.call(HibitIdExposeRPCMethod.CONNECT, {
chainId,
Expand Down Expand Up @@ -334,22 +332,22 @@ export class HibitIdWallet {

private onRpcLoginChanged = (input: LoginChangedRequest) => {
console.debug('[sdk on LoginChanged]', { input })
if (!this._connectPromise) {
return
}
// only show iframe during connection
this._hasSession = input.isLogin
if (!input.isLogin) {
this.showIframe(true)
sessionStorage.removeItem(LOGIN_SESSION_KEY)
if (this._connectPromise) {
this.showIframe(true)
}
} else {
sessionStorage.setItem(LOGIN_SESSION_KEY, input.sub || '')
if (!this._controller) {
this._controller = new HibitIdController(this.toggleIframe, this.handleControllerMove)
}
if (this._hasSession) {
return
if (this._connectPromise) {
this.showIframe()
this._controller?.setOpen(true)
}
this.showIframe()
this._controller?.setOpen(true)
sessionStorage.setItem(LOGIN_SESSION_KEY, input.sub || '')
}
}

Expand Down

0 comments on commit bb09e90

Please sign in to comment.