X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/3a530766c12a5677e6b5f8c54cd3a61f8e6934b4..da3ae51b7b3b63561a9e1c47c965f45a08225d34:/src/store/search-bar/search-bar-actions.ts diff --git a/src/store/search-bar/search-bar-actions.ts b/src/store/search-bar/search-bar-actions.ts index 1e1810e7..3d6d3fdc 100644 --- a/src/store/search-bar/search-bar-actions.ts +++ b/src/store/search-bar/search-bar-actions.ts @@ -3,6 +3,9 @@ // SPDX-License-Identifier: AGPL-3.0 import { unionize, ofType, UnionOf } from "~/common/unionize"; +import { Dispatch } from 'redux'; +import { RootState } from '~/store/store'; +import { ServiceRepository } from '~/services/services'; export const searchBarActions = unionize({ SET_CURRENT_VIEW: ofType(), @@ -12,4 +15,15 @@ export const searchBarActions = unionize({ export type SearchBarActions = UnionOf; -export const goToView = (currentView: string) => searchBarActions.SET_CURRENT_VIEW(currentView); \ No newline at end of file +export const goToView = (currentView: string) => searchBarActions.SET_CURRENT_VIEW(currentView); + +export const saveRecentQuery = (query: string) => + (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + services.searchQueriesService.saveRecentQuery(query); + }; + +export const loadRecentQueries = () => + (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const recentSearchQueries = services.searchQueriesService.getRecentQueries(); + return recentSearchQueries || []; + }; \ No newline at end of file