Skip to content

Commit

Permalink
⚡️ Lazy restore session by checking localStorage first (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong authored Jun 29, 2023
1 parent 3875e34 commit 051b62b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/store/modules/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,19 @@ const actions = {
},

async restoreSession({ dispatch }) {
// HACK: check for localStorage session before init-ing wallet connector lib
// wallet connector lib is a huge js
let hasSession = false;
try {
if (window.localStorage) {
hasSession = !!window.localStorage.getItem(
'likecoin_wallet_connector_session'
);
}
} catch (err) {
console.error(err);
}
if (!hasSession) return;
const connector = await dispatch('getConnector');
const session = connector.restoreSession();
if (session) {
Expand Down

0 comments on commit 051b62b

Please sign in to comment.