Skip to content

Commit

Permalink
👔 Use session wallet to determine connected user
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraHuang22 committed Sep 20, 2024
1 parent 5dad640 commit 21ac94b
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/AuthRequiredView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default {
},
mounted() {
const { login } = this.$route.query;
if (!this.walletIsMatchedSession && login) {
if (!this.getSessionWallet && login) {
this.onClickLogin();
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/EventModal/Collect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ export default {
try {
switch (method) {
case 'crypto': {
if (!this.getAddress) {
if (!this.getSessionWallet) {
const isConnected = await this.connectWallet();
if (!isConnected) return;
}
Expand Down Expand Up @@ -755,7 +755,7 @@ export default {
await this.collectNFTWithStripe(classId, { memo: this.memo });
break;
case 'free': {
if (!this.getAddress) {
if (!this.getSessionWallet) {
const isConnected = await this.connectWallet();
if (!isConnected) return;
}
Expand Down
19 changes: 10 additions & 9 deletions src/components/SiteHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</Dropdown>

<ButtonV2
v-if="!loginAddress"
v-if="!getSessionWallet"
class="hidden laptop:flex"
preset="secondary"
:text="$t('header_button_connect_to_wallet')"
Expand All @@ -70,7 +70,7 @@

<Dropdown class="hidden laptop:block ml-[4px]">
<template #trigger="{ toggle }">
<div v-if="loginAddress" class="relative">
<div v-if="getSessionWallet" class="relative">
<Identity
class="cursor-pointer"
:avatar-url="walletUserAvatar"
Expand Down Expand Up @@ -136,7 +136,7 @@

{{ /* phone version */ }}
<ButtonV2
v-if="!loginAddress"
v-if="!getSessionWallet"
class="laptop:hidden"
preset="plain"
@click="handleOpenSlider"
Expand Down Expand Up @@ -171,7 +171,7 @@
@close="isShowMobileMenu = false"
>
<ButtonV2
v-if="!loginAddress"
v-if="!getSessionWallet"
class="w-full"
preset="secondary"
@click="handleConnectWallet"
Expand Down Expand Up @@ -292,6 +292,7 @@ export default {
'getUserId',
'getNotificationCount',
'shoppingCartBookProductList',
'getSessionWallet',
]),
currentLocale() {
return this.$i18n.locale;
Expand All @@ -317,10 +318,10 @@ export default {
},
},
async mounted() {
await this.restoreSession();
await this.restoreAuthSession();
},
methods: {
...mapActions(['updatePreferences', 'userLogout']),
...mapActions(['updatePreferences', 'userLogout', 'restoreAuthSession']),
handleClickGoStore() {
logTrackerEvent(this, 'site_header', 'site_header_click_store', '', 1);
},
Expand Down Expand Up @@ -366,7 +367,7 @@ export default {
this.$router.push(
this.localeLocation({
name: 'bookshelf',
params: { id: this.loginAddress },
params: { id: this.getSessionWallet },
query: { tab: 'collected' },
})
);
Expand All @@ -392,12 +393,12 @@ export default {
handleOpenSlider() {
this.isShowMobileMenu = true;
if (this.loginAddress) {
if (this.getSessionWallet) {
logTrackerEvent(
this,
'site_menu',
'site_menu_click_slider_menu',
this.loginAddress,
this.getSessionWallet,
1
);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/mixins/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export default {
'walletIsMatchedSession',
'walletIsLoggingIn',
'loginAddress',
'getToken',
'getSessionWallet',
'getIsRestoringSession',
]),
hasConnectedWallet() {
return !!this.getAddress && !!this.walletMethodType;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_id/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export default {
1
);
if (!this.getAddress) {
if (!this.getSessionWallet) {
const isConnected = await this.connectWallet();
if (!isConnected) return;
this.walletFetchLIKEBalance();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/bookshelf/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default {
'walletFollowees',
]),
wallet() {
return this.loginAddress;
return this.getSessionWallet;
},
},
watch: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/nft/claim/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ export default {
);
},
claimingAddress() {
return this.loginAddress;
return this.getSessionWallet;
},
claimingEmail() {
return this.walletEmail || this.walletEmailUnverified;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/reader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ export default {
await this.fetchISCNMetadata();
await this.restoreSession();
// TODO: use loginAddress
if (this.getAddress) {
if (this.getSessionWallet) {
await Promise.all([
this.fetchUserCollectedCount(),
this.updateNFTOwners(),
]);
if (
(!this.userCollectedCount && this.isLoginRequired) ||
(this.nftCollectorWalletAddress &&
this.nftCollectorWalletAddress !== this.getAddress)
this.nftCollectorWalletAddress !== this.getSessionWallet)
) {
this.$router.replace(
this.localeLocation({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/shopping-cart/wnft.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export default {
1
);
try {
if (!this.getAddress) {
if (!this.getSessionWallet) {
const isConnected = await this.connectWallet();
if (!isConnected) return;
} else {
Expand Down

0 comments on commit 21ac94b

Please sign in to comment.