Skip to content

Commit

Permalink
🔧 Get 100 items for listing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Feb 4, 2025
1 parent 4debd67 commit 1f0cd7c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/pages/store/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,11 @@ export default {
...getCMSTagIdsForRecommendedBookstoreItemsByLocale(i18n.locale).map(
tagId =>
store
.dispatch('lazyFetchBookstoreCMSProductsByTagId', { tagId, t })
.dispatch('lazyFetchBookstoreCMSProductsByTagId', {
tagId,
t,
limit: 100,
})
.catch(() => ({ records: [] }))
),
];
Expand Down
19 changes: 13 additions & 6 deletions src/store/modules/nft.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ const actions = {
},
async fetchBookstoreCMSProductsByTagId(
{ commit, getters },
{ tagId, t, offset }
{ tagId, t, limit, offset }
) {
if (
!tagId ||
Expand All @@ -1100,7 +1100,7 @@ const actions = {
commit(fetchingMutation, { id: tagId, value: true });

const { data } = await this.$api.get(
api.fetchBookstoreCMSProductsByTagId(tagId, { t, offset })
api.fetchBookstoreCMSProductsByTagId(tagId, { t, offset, limit })
);

commit(TYPES.NFT_SET_BOOKSTORE_CMS_PRODUCTS_BY_TAG_ID, {
Expand All @@ -1118,22 +1118,29 @@ const actions = {
commit(fetchingMutation, { id: tagId, value: false });
}
},
async fetchMoreBookstoreCMSProductsByTagId({ dispatch, getters }, { tagId }) {
async fetchMoreBookstoreCMSProductsByTagId(
{ dispatch, getters },
{ tagId, limit }
) {
const offset = getters.nftGetBookstoreCMSProductsPaginationOffsetByTagId(
tagId
);
if (!offset) return;
await dispatch('fetchBookstoreCMSProductsByTagId', { tagId, offset });
await dispatch('fetchBookstoreCMSProductsByTagId', {
tagId,
offset,
limit,
});
},
async lazyFetchBookstoreCMSProductsByTagId(
{ dispatch, getters },
{ tagId, t }
{ tagId, t, limit }
) {
if (!tagId || getters.nftGetBookstoreCMSProductsByTagIdHasFetched(tagId)) {
return;
}

await dispatch('fetchBookstoreCMSProductsByTagId', { tagId, t });
await dispatch('fetchBookstoreCMSProductsByTagId', { tagId, t, limit });
},
};

Expand Down

0 comments on commit 1f0cd7c

Please sign in to comment.