@empathyco/x-components
Version:
Empathy X Components
75 lines (72 loc) • 2.9 kB
JavaScript
import { setConfig, mergeConfig } from '../../../store/utils/config-store.utils.js';
import { setQuery } from '../../../store/utils/query.utils.js';
import { localStorageService } from '../../../utils/storage.js';
import { addQueryToHistory } from './actions/add-query-to-history.action.js';
import { loadHistoryQueriesFromBrowserStorage } from './actions/load-history-queries-from-browser-storage.action.js';
import { refreshSession } from './actions/refresh-session.action.js';
import { removeFromHistory } from './actions/remove-query-from-history.action.js';
import { setHistoryQueries } from './actions/set-history-queries.action.js';
import { setUrlParams } from './actions/set-url-params.action.js';
import { toggleHistoryQueries } from './actions/toggle-history-queries.action.js';
import { updateHistoryQueriesWithSearchResponse } from './actions/update-history-queries-with-search-response.action.js';
import { HISTORY_QUERIES_ENABLED_KEY } from './constants.js';
import { historyQueriesWithResults } from './getters/history-queries-with-results.getter.js';
import { historyQueries } from './getters/history-queries.getter.js';
import { normalizedQuery } from './getters/normalized-query.getter.js';
import { sessionHistoryQueries } from './getters/session-history-queries.getter.js';
import { storageKey } from './getters/storage-key.getter.js';
/**
* {@link XStoreModule} For the history-queries module.
*
* @internal
*/
const historyQueriesXStoreModule = {
state: () => ({
config: {
debounceInMs: 150,
maxItemsToStore: 50,
hideIfEqualsQuery: true,
sessionTTLInMs: 30 * 60 * 1000,
},
query: '',
historyQueries: [],
sessionTimeStampInMs: Date.now(),
isEnabled: localStorageService.getItem(HISTORY_QUERIES_ENABLED_KEY) ?? true,
}),
getters: {
historyQueries,
normalizedQuery,
historyQueriesWithResults,
sessionHistoryQueries,
storageKey,
},
mutations: {
setHistoryQueries(state, historyQueries) {
state.historyQueries = historyQueries;
},
setSessionTimeStamp(state, sessionTimeStamp) {
state.sessionTimeStampInMs = sessionTimeStamp;
},
setQuery,
setConfig,
mergeConfig,
setIsEnabled(state, isEnabled) {
state.isEnabled = isEnabled;
},
setSearchSelectedFilters(state, filters) {
state.historyQueries[0].selectedFilters = filters;
},
},
actions: {
addQueryToHistory,
loadHistoryQueriesFromBrowserStorage,
refreshSession,
removeFromHistory,
setHistoryQueries,
setUrlParams,
toggleHistoryQueries,
updateHistoryQueriesWithSearchResponse,
},
};
export { historyQueriesXStoreModule };
//# sourceMappingURL=module.js.map