From c52e00f13e7b311acf4f20ad7d34258d2708dbab Mon Sep 17 00:00:00 2001 From: William Chong Date: Fri, 25 Oct 2024 20:30:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Simplify=20login=20log?= =?UTF-8?q?ic=20and=20reduce=20await=20post=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mixins/wallet-login.js | 12 +++-------- src/store/modules/wallet.js | 43 +++++++++++-------------------------- 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/src/mixins/wallet-login.js b/src/mixins/wallet-login.js index cfced5519..5e271f6d2 100644 --- a/src/mixins/wallet-login.js +++ b/src/mixins/wallet-login.js @@ -17,11 +17,7 @@ export default { 'signLogin', 'openAuthcoreModal', ]), - async connectWallet({ - shouldSkipLogin = false, - isOpenAuthcore = false, - isSignUp = false, - } = {}) { + async connectWallet({ isOpenAuthcore = false, isSignUp = false } = {}) { try { logTrackerEvent( this, @@ -54,15 +50,13 @@ export default { 1 ); - const res = await (shouldSkipLogin - ? this.initWallet(connection) - : this.initWalletAndLogin(connection)); + const res = await this.initWalletAndLogin(connection); if (res) { logTrackerEvent( this, 'user', - `connect_wallet_done${shouldSkipLogin ? '' : '_with_login'}`, + `connect_wallet_done$_with_login`, 'connect_wallet_done', 1 ); diff --git a/src/store/modules/wallet.js b/src/store/modules/wallet.js index 66943ee2d..b470d15b9 100644 --- a/src/store/modules/wallet.js +++ b/src/store/modules/wallet.js @@ -360,7 +360,7 @@ const actions = { method: getters.walletMethodType, event: 'login', }); - dispatch('walletFetchSessionUserData', { shouldSkipUserInfo: true }); + dispatch('walletFetchSessionUserData'); } else if (getters.getAddress) { // Re-login if the wallet address is different from session await dispatch('signLogin'); @@ -385,26 +385,11 @@ const actions = { return connector; }, - async handleConnectorRedirect( - { dispatch, getters }, - { method, params, isLogin = true } - ) { + async handleConnectorRedirect({ dispatch }, { method, params }) { const connector = await dispatch('getConnector'); const connection = await connector.handleRedirect(method, params); if (connection) { - if (isLogin) { - await dispatch('initWalletAndLogin', connection); - } else { - await dispatch('initWallet', connection); - if (getters.walletIsMatchedSession) { - await setLoggerUser(this, { - wallet: getters.loginAddress, - method: getters.walletMethodType, - event: 'login', - }); - dispatch('walletFetchSessionUserData', { shouldSkipUserInfo: true }); - } - } + await dispatch('initWalletAndLogin', connection); } return connection; }, @@ -496,20 +481,16 @@ const actions = { await dispatch('initWallet', { accounts, method }); if (getters.walletIsMatchedSession) { await setLoggerUser(this, { wallet: getters.loginAddress, method }); - dispatch('walletFetchSessionUserData', { shouldSkipUserInfo: true }); + dispatch('walletFetchSessionUserData'); } } }, - async initIfNecessary({ dispatch }, { isLogin = true } = {}) { + async initIfNecessary({ dispatch }) { const connector = await dispatch('getConnector'); const connection = await connector.initIfNecessary(); if (connection) { - if (isLogin) { - await dispatch('initWalletAndLogin', connection); - } else { - await dispatch('initWallet', connection); - } + await dispatch('initWalletAndLogin', connection); } }, @@ -869,15 +850,17 @@ const actions = { }, async walletFetchSessionUserData( { dispatch }, - { shouldSkipUserInfo = false } = {} + { awaitForWalletEvents = false } = {} ) { const promises = []; - if (!shouldSkipUserInfo) { - promises.push(dispatch('walletFetchSessionUserInfo')); + promises.push(dispatch('walletFetchSessionUserInfo')); + const walletEventPromise = dispatch('walletFetchFollowees').then(() => + dispatch('fetchWalletEvents', { shouldFetchDetails: false }) + ); + if (awaitForWalletEvents) { + promises.push(walletEventPromise); } - promises.push(dispatch('walletFetchFollowees')); await Promise.all(promises); - await dispatch('fetchWalletEvents', { shouldFetchDetails: false }); }, async signLogin({ state, commit, dispatch }) { // Do not trigger login if the window is not focused From e27625266a9062980907ba3a60ae31eb6fd5ec06 Mon Sep 17 00:00:00 2001 From: William Chong <6198816+williamchong@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:42:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20event=20typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ng Wing Tat, David --- src/mixins/wallet-login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/wallet-login.js b/src/mixins/wallet-login.js index 5e271f6d2..1824bf65d 100644 --- a/src/mixins/wallet-login.js +++ b/src/mixins/wallet-login.js @@ -56,7 +56,7 @@ export default { logTrackerEvent( this, 'user', - `connect_wallet_done$_with_login`, + `connect_wallet_done_with_login`, 'connect_wallet_done', 1 );