Skip to content

Commit

Permalink
fix(en-482): fixed duplicated search requests (#6495)
Browse files Browse the repository at this point in the history
  • Loading branch information
dawid-ziobro authored Oct 28, 2021
1 parent a7eea6e commit 20b2b27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
8 changes: 8 additions & 0 deletions packages/core/docs/core/changelog/6495.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
description: 'Fixed duplicated search requests',
link: 'https://github.com/vuestorefront/vue-storefront/pull/6495',
isBreaking: false,
breakingChanges: [],
author: 'Dawid Ziobro',
linkToGitHubAccount: 'https://github.com/dawid-ziobro'
};
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ import {
SfIcon,
SfSelect
} from '@storefront-ui/vue';
import { onSSR } from '@vue-storefront/core';
import LazyHydrate from 'vue-lazy-hydration';
export default {
Expand All @@ -105,15 +104,11 @@ export default {
setup() {
const th = useUiHelpers();
const { toggleFilterSidebar, isCategoryGridView, changeToCategoryGridView, changeToCategoryListView } = useUiState();
const { result, search } = useFacet();
const { result } = useFacet();
const sortBy = computed(() => facetGetters.getSortOptions(result.value));
const facets = computed(() => facetGetters.getGrouped(result.value, ['color', 'size']));
onSSR(async () => {
await search(th.getFacetsFromURL());
});
return {
th,
sortBy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ import {
import { ref, computed, onMounted } from '@vue/composition-api';
import { useFacet, facetGetters } from '<%= options.generate.replace.composables %>';
import { useUiHelpers, useUiState } from '~/composables';
import { onSSR } from '@vue-storefront/core';
import Vue from 'vue';
export default {
Expand All @@ -107,9 +106,9 @@ export default {
SfHeading
},
setup(props, context) {
const { changeFilters, isFacetColor, getFacetsFromURL } = useUiHelpers();
const { changeFilters, isFacetColor } = useUiHelpers();
const { toggleFilterSidebar, isFilterSidebarOpen } = useUiState();
const { search, result, loading } = useFacet();
const { result } = useFacet();
const facets = computed(() => facetGetters.getGrouped(result.value, ['color', 'size']));
const selectedFilters = ref({});
Expand Down Expand Up @@ -150,25 +149,18 @@ export default {
changeFilters(selectedFilters.value);
};
onSSR(async () => {
await search(getFacetsFromURL());
setSelectedFilters();
});
onMounted(() => {
context.root.$scrollTo(context.root.$el, 2000);
setSelectedFilters();
});
return {
loading,
facets,
isFacetColor,
selectFilter,
isFilterSelected,
isFilterSidebarOpen,
toggleFilterSidebar,
selectedFilters,
clearFilters,
applyFilters
};
Expand Down

0 comments on commit 20b2b27

Please sign in to comment.