Skip to content

Commit

Permalink
load more NFTs, but from the end of the array
Browse files Browse the repository at this point in the history
  • Loading branch information
tempe-techie committed Oct 3, 2023
1 parent de17f10 commit 639d3bb
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pages/nft/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
computed: {
showLoadMoreButton() {
return this.allNftsArrayLength > this.allNftsIndexStart;
return this.allNftsIndexEnd > 0;
}
},
Expand Down Expand Up @@ -183,19 +183,17 @@ export default {
this.allNftsArrayLength = await launchpadContract.getNftContractsArrayLength();
}
// set the end index, if 0
// set the start and end index, if end index is 0
if (this.allNftsIndexEnd === 0) {
this.allNftsIndexEnd = this.$config.nftLaunchpadLatestItems - 1;
this.allNftsIndexEnd = this.allNftsArrayLength - 1;
if (this.allNftsArrayLength < this.$config.nftLaunchpadLatestItems) {
this.allNftsIndexEnd = this.allNftsArrayLength - 1;
this.allNftsIndexStart = 0;
} else {
this.allNftsIndexStart = this.allNftsArrayLength - this.$config.nftLaunchpadLatestItems;
}
}
console.log("allNftsArrayLength: " + this.allNftsArrayLength);
console.log("allNftsIndexStart: " + this.allNftsIndexStart);
console.log("allNftsIndexEnd: " + this.allNftsIndexEnd);
// get last NFTs
const lNfts = await launchpadContract.getNftContracts(this.allNftsIndexStart, this.allNftsIndexEnd);
const lNftsWritable = [...lNfts]; // copy the lNfts array to make it writable (for reverse() method)
Expand All @@ -205,11 +203,16 @@ export default {
await this.parseNftsArray(lNftsWritable, this.lastNfts, provider);
this.allNftsIndexStart = this.allNftsIndexEnd + 1;
this.allNftsIndexEnd = this.allNftsIndexEnd + this.$config.nftLaunchpadLatestItems;
if (this.allNftsIndexEnd > this.$config.nftLaunchpadLatestItems) {
this.allNftsIndexEnd = this.allNftsIndexEnd - this.$config.nftLaunchpadLatestItems;
} else {
this.allNftsIndexEnd = 0;
}
if (this.allNftsIndexEnd >= this.allNftsArrayLength) {
this.allNftsIndexEnd = this.allNftsArrayLength - 1;
if (this.allNftsIndexStart > this.$config.nftLaunchpadLatestItems) {
this.allNftsIndexStart = this.allNftsIndexStart - this.$config.nftLaunchpadLatestItems;
} else {
this.allNftsIndexStart = 0;
}
this.waitingData = false;
Expand Down

1 comment on commit 639d3bb

@vercel
Copy link

@vercel vercel bot commented on 639d3bb Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.