Skip to content

Commit

Permalink
fix: mobile stuck state
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Nov 14, 2024
1 parent ecd1d05 commit e5f3450
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-dapp/src/dapp-client/DAppClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ export class DAppClient extends Client {
this.debounceSetActiveAccount = true
this._initPromise = undefined
this.postMessageTransport = this.p2pTransport = this.walletConnectTransport = undefined
if (this.multiTabChannel.isLeader()) {
if (this.multiTabChannel.isLeader() || isMobileOS(window)) {
await transport.disconnect()
this.openRequestsOtherTabs.clear()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
this.signClient?.core.pairing.events.removeAllListeners('pairing_expire')
}

private abortErrorBuilder() {
if (!this.messageIds.length) {
return
}

const errorResponse: any = {
type: BeaconMessageType.Disconnect,
id: this.messageIds.pop(),
errorType: BeaconErrorType.ABORTED_ERROR
}
this.session && this.notifyListeners(this.getTopicFromSession(this.session), errorResponse)
this.messageIds = [] // reset
}

private onStorageMessageHandler(type: string) {
if (!this.isMobileOS()) {
return
Expand All @@ -215,11 +201,11 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
logger.debug('onStorageMessageHandler', type)

if (type === 'RESET') {
this.abortErrorBuilder()
this.clearEvents()
// no need to invoke `closeSignClinet` as the other tab already closed the connection
this.signClient = undefined
this.clearState()
this.messageIds = []

return
}
Expand Down Expand Up @@ -747,7 +733,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient {

public async close() {
this.storage.backup()
this.abortErrorBuilder()
await this.closePairings()
this.unsubscribeFromEncryptedMessages()
this.messageIds = []
Expand Down

0 comments on commit e5f3450

Please sign in to comment.