Skip to content

Commit

Permalink
πŸ› Fix nftId mismatch if read owned class from non-owned nft page (#1852)
Browse files Browse the repository at this point in the history
* πŸ› Fix nftId mismatch if read owned class from non-owned nft page

* ♻️ Use loginAddress for ownNFT vars
  • Loading branch information
williamchong authored Oct 2, 2024
1 parent 41dd69b commit 46e35cf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/NFTPortfolio/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
:display-state="nftDisplayState"
:is-nft-book="nftIsNFTBook"
:portfolio-tab="portfolioTab"
:is-content-viewable="!(nftIsNFTBook && !ownCount)"
:is-content-viewable="!(nftIsNFTBook && !isOwningNFT)"
:is-content-downloadable="!nftIsDownloadHidden"
:collect-expiry-time="collectExpiryTime"
@collect="handleClickCollect"
Expand Down
12 changes: 10 additions & 2 deletions src/mixins/nft.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ export default {
id,
displayName: owner?.displayName || id,
collectedCount: this.collectorMap[id].length,
collectedNftIds: this.collectorMap[id],
collectedFirstNFTId: this.collectorMap[id][0],
avatar: owner?.avatar || getIdenticonAvatar(id),
isCivicLiker:
Expand All @@ -579,15 +580,22 @@ export default {
},
ownCount() {
const collector = this.populatedCollectors.find(
({ id }) => id === this.getAddress
({ id }) => id === this.loginAddress
);
return collector?.collectedCount || 0;
},
isOwningNFT() {
if (!this.nftId) return this.ownCount > 0;
const collector = this.populatedCollectors.find(
({ id }) => id === this.loginAddress
);
return (collector?.collectedNftIds || []).includes(this.nftId);
},
nftClassDetailsPageURL() {
return `/nft/class/${this.classId}?referrer=${this.getAddress}`;
},
nftIdCollectedFirstByUser() {
const ownNFT = this.collectorMap[this.getAddress];
const ownNFT = this.collectorMap[this.loginAddress];
return ownNFT?.[0];
},
nftIdCollectNext() {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/nft/class/_classId/_nftId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
:collector-count="ownerCount"
:class-collection-type="nftClassCollectionType"
:class-collection-name="nftClassCollectionName"
:is-content-viewable="!(nftIsNFTBook && !ownCount)"
:is-content-viewable="!(nftIsNFTBook && !isOwningNFT)"
:is-content-downloadable="!nftIsDownloadHidden"
:is-nft-book="nftIsNFTBook"
@view-content="handleViewContent"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/nft/class/_classId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
:is-collectable="nftIsCollectable"
:collected-count="collectedCount"
:collector-count="ownerCount"
:is-content-viewable="!(nftIsNFTBook && !ownCount)"
:is-content-viewable="!(nftIsNFTBook && !isOwningNFT)"
:is-loading="uiIsOpenCollectModal && isCollecting"
:url="externalUrl"
@collect="handleCollectFromPriceSection"
Expand Down

0 comments on commit 46e35cf

Please sign in to comment.