From 232d1148842d2436092435d4e1c633ceb00ecb75 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Thu, 19 Oct 2023 13:52:27 +0200 Subject: [PATCH 1/3] fix(history-queries): selected filters now working for legacy history queries saved in storage without them EMP-2528 --- packages/x-components/src/x-modules/facets/wiring.ts | 2 +- .../load-history-queries-from-browser-storage.action.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/x-components/src/x-modules/facets/wiring.ts b/packages/x-components/src/x-modules/facets/wiring.ts index cd7f2ecf3e..6bb0fb64e3 100644 --- a/packages/x-components/src/x-modules/facets/wiring.ts +++ b/packages/x-components/src/x-modules/facets/wiring.ts @@ -173,7 +173,7 @@ export const setSelectedFiltersFromPreview = wireCommit( */ export const setFiltersFromHistoryQueries = wireCommit( 'setFilters', - ({ eventPayload: { selectedFilters } }) => selectedFilters + ({ eventPayload: { selectedFilters } }) => selectedFilters ?? [] ); /** diff --git a/packages/x-components/src/x-modules/history-queries/store/actions/load-history-queries-from-browser-storage.action.ts b/packages/x-components/src/x-modules/history-queries/store/actions/load-history-queries-from-browser-storage.action.ts index 2a3f58d158..2752b6ea04 100644 --- a/packages/x-components/src/x-modules/history-queries/store/actions/load-history-queries-from-browser-storage.action.ts +++ b/packages/x-components/src/x-modules/history-queries/store/actions/load-history-queries-from-browser-storage.action.ts @@ -13,6 +13,7 @@ import { HistoryQueriesXStoreModule } from '../types'; // eslint-disable-next-line max-len export const loadHistoryQueriesFromBrowserStorage: HistoryQueriesXStoreModule['actions']['loadHistoryQueriesFromBrowserStorage'] = ({ commit, getters }) => { - const historyQueries = localStorageService.getItem(getters.storageKey) ?? []; - commit('setHistoryQueries', historyQueries); + const historyQueries = + localStorageService.getItem(getters.storageKey) ?? []; + commit('setHistoryQueries', [historyQueries].flat()); }; From 5981913e62a5910f0951bd7a76f57219309a409e Mon Sep 17 00:00:00 2001 From: Guillermo Date: Thu, 19 Oct 2023 14:02:28 +0200 Subject: [PATCH 2/3] chore: fix search module wiring too --- packages/x-components/src/x-modules/search/wiring.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/x-components/src/x-modules/search/wiring.ts b/packages/x-components/src/x-modules/search/wiring.ts index a85d03136c..7679bce076 100644 --- a/packages/x-components/src/x-modules/search/wiring.ts +++ b/packages/x-components/src/x-modules/search/wiring.ts @@ -219,9 +219,9 @@ export const setSearchSelectedFiltersFromPreview = wireCommit( * * @public */ -export const setSearchSelectedFiltersFromPreviewable = wireCommit( +export const setSearchSelectedFiltersFromHistoryQuery = wireCommit( 'setSelectedFilters', - ({ eventPayload: { selectedFilters } }) => selectedFilters + ({ eventPayload: { selectedFilters } }) => selectedFilters ?? [] ); /** @@ -294,6 +294,6 @@ export const searchWiring = createWiring({ setSearchExtraParams }, UserSelectedAHistoryQuery: { - setSearchSelectedFiltersFromPreviewable + setSearchSelectedFiltersFromHistoryQuery } }); From 4d3704724b43bc8231edc63fea4f2107d40b2ed8 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Fri, 20 Oct 2023 08:47:13 +0200 Subject: [PATCH 3/3] chore: reverse flat --- .../load-history-queries-from-browser-storage.action.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/x-components/src/x-modules/history-queries/store/actions/load-history-queries-from-browser-storage.action.ts b/packages/x-components/src/x-modules/history-queries/store/actions/load-history-queries-from-browser-storage.action.ts index 2752b6ea04..2a3f58d158 100644 --- a/packages/x-components/src/x-modules/history-queries/store/actions/load-history-queries-from-browser-storage.action.ts +++ b/packages/x-components/src/x-modules/history-queries/store/actions/load-history-queries-from-browser-storage.action.ts @@ -13,7 +13,6 @@ import { HistoryQueriesXStoreModule } from '../types'; // eslint-disable-next-line max-len export const loadHistoryQueriesFromBrowserStorage: HistoryQueriesXStoreModule['actions']['loadHistoryQueriesFromBrowserStorage'] = ({ commit, getters }) => { - const historyQueries = - localStorageService.getItem(getters.storageKey) ?? []; - commit('setHistoryQueries', [historyQueries].flat()); + const historyQueries = localStorageService.getItem(getters.storageKey) ?? []; + commit('setHistoryQueries', historyQueries); };