Skip to content

Commit

Permalink
Catch wallet abort connection error (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
GusevPM authored Aug 6, 2023
1 parent 1025e67 commit 2652cfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ export default new Vuex.Store({
commit('setWarning', null)
}
}
});
});
11 changes: 9 additions & 2 deletions src/utils/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class Wallet {

static getLastUsedAccount() {
const accounts = localStorage.getItem('beacon:accounts');
if(!accounts) return null

const communicationPeersDapp = localStorage.getItem('beacon:communication-peers-dapp');
const postmessagePeersDapp = localStorage.getItem('beacon:postmessage-peers-dapp');
let peers = [];
Expand All @@ -74,7 +76,6 @@ export class Wallet {
peers = [...peers, ...JSON.parse(postmessagePeersDapp)]
}

if(!accounts) return null
const parsedAccounts = JSON.parse(accounts);
const connectionTimes = parsedAccounts.map(item => item.connectedAt);
const recentConnectionTime = Math.max(...connectionTimes);
Expand Down Expand Up @@ -115,7 +116,13 @@ export class Wallet {
Wallet.isPermissionGiven = true;
resolve();
})
.finally(() => reject())
.catch(e => {
if (e.title && e.title.toUpperCase() === 'ABORTED') {
resolve();
} else {
reject();
}
})
})
}

Expand Down

0 comments on commit 2652cfc

Please sign in to comment.