Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
Merge branch '#554/filter-count-issue-on-initial-load' of https://git…
Browse files Browse the repository at this point in the history
…hub.com/hotwax/vsf-capybara into #554/filter-count-issue-on-initial-load
  • Loading branch information
ymaheshwari1 committed Jan 11, 2021
2 parents 0343bd1 + b854467 commit 406c7f0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pages/Category.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ import {
const THEME_PAGE_SIZE = 12;
const LAZY_LOADING_ACTIVATION_BREAKPOINT = 1024;
var unsubscribeFromStoreAction = ''
var aggs = ''
const composeInitialPageState = async (store, route, forceLoad = false) => {
try {
Expand Down Expand Up @@ -434,6 +436,11 @@ export default {
async asyncData ({ store, route, context }) {
// this is for SSR purposes to prefetch data - and it's always executed before parent component methods
if (context) context.output.cacheTags.add('category')
unsubscribeFromStoreAction = store.subscribeAction(action => {
if (action.type === 'category-next/loadAvailableFiltersFrom') {
aggs = action.payload.aggregations;
}
});
await composeInitialPageState(store, route);
},
async beforeRouteEnter (to, from, next) {
Expand All @@ -457,17 +464,12 @@ export default {
}
},
mounted () {
this.unsubscribeFromStoreAction = this.$store.subscribeAction(action => {
if (action.type === 'category-next/loadAvailableFiltersFrom') {
this.aggregations = action.payload.aggregations;
}
});
this.$bus.$on('product-after-list', this.initPagination);
window.addEventListener('resize', this.getBrowserWidth);
this.getBrowserWidth();
},
beforeDestroy () {
this.unsubscribeFromStoreAction();
unsubscribeFromStoreAction();
this.$bus.$off('product-after-list', this.initPagination);
window.removeEventListener('resize', this.getBrowserWidth);
},
Expand Down Expand Up @@ -548,9 +550,9 @@ export default {
return aggregations
.reduce((result, aggregation) => {
const bucket =
this.aggregations &&
this.aggregations[aggregation] &&
this.aggregations[aggregation].buckets.find(
aggs &&
aggs[aggregation] &&
aggs[aggregation].buckets.find(
bucket => String(bucket.key) === String(filter.id)
);
Expand Down

0 comments on commit 406c7f0

Please sign in to comment.