Skip to content

Commit b819901

Browse files
committed
#1754 Load activity chart data when tab is clicked
1 parent 450e185 commit b819901

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

components/rmrk/Gallery/CollectionItem.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export default class CollectionItem extends mixins(ChainMixin, PrefixMixin) {
198198
protected total = 0
199199
protected stats: NFT[] = []
200200
protected priceData: any = []
201+
private statsLoaded = false
201202
202203
get isLoading(): boolean {
203204
return this.$apollo.queries.collection.loading
@@ -256,7 +257,6 @@ export default class CollectionItem extends mixins(ChainMixin, PrefixMixin) {
256257
public created(): void {
257258
this.checkId()
258259
this.checkActiveTab()
259-
this.loadStats()
260260
this.$apollo.addSmartQuery('collection', {
261261
query: collectionById,
262262
client: this.urlPrefix,
@@ -297,6 +297,7 @@ export default class CollectionItem extends mixins(ChainMixin, PrefixMixin) {
297297
.then(({ data }) => data?.nFTEntities?.nodes || [])
298298
.then((nfts) => {
299299
this.stats = nfts
300+
this.statsLoaded = true
300301
this.loadPriceData()
301302
})
302303
}
@@ -353,12 +354,19 @@ export default class CollectionItem extends mixins(ChainMixin, PrefixMixin) {
353354
354355
@Watch('activeTab')
355356
protected onTabChange(val: string, oldVal: string): void {
356-
if (shouldUpdate(val, oldVal)) {
357+
let queryTab = this.$route.query.tab
358+
359+
if (shouldUpdate(val, oldVal) && (queryTab !== val)) {
357360
this.$router.replace({
358361
path: String(this.$route.path),
359362
query: { tab: val },
360363
})
361364
}
365+
366+
// Load chart data once when clicked on activity tab for the first time.
367+
if (val === 'activity' && !this.statsLoaded) {
368+
this.loadStats()
369+
}
362370
}
363371
364372
get iframeSettings(): Record<string, unknown> {

0 commit comments

Comments
 (0)