-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(query-preview): implementation with 2 lists
- Loading branch information
1 parent
17f6daf
commit 9b56106
Showing
9 changed files
with
159 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../x-modules/queries-preview/store/actions/fetch-and-save-query-preview-non-cache.action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { QueriesPreviewXStoreModule } from '../types'; | ||
|
||
/** | ||
* Default implementation for the {@link QueriesPreviewActions.fetchAndSaveQueryPreview}. | ||
* | ||
* @param _context - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions, | ||
* provided by Vuex. | ||
* @param request - The query preview request to make. | ||
* @returns A Promise of a SearchResponse when it fetches the results. | ||
* | ||
* @public | ||
*/ | ||
// eslint-disable-next-line max-len | ||
export const fetchAndSaveQueryPreviewNonCache: QueriesPreviewXStoreModule['actions']['fetchAndSaveQueryPreviewNonCache'] = | ||
({ dispatch, commit }, request) => { | ||
const { query } = request; | ||
|
||
if (!query) { | ||
return; | ||
} | ||
//const persistInCache = request.extraParams?.persistInCache as boolean; | ||
|
||
commit('setQueryPreviewNonCached', { | ||
request, | ||
results: [], | ||
status: 'loading', | ||
totalResults: 0 | ||
}); | ||
|
||
return dispatch('fetchQueryPreview', request) | ||
.then(response => { | ||
commit('setQueryPreviewNonCached', { | ||
request, | ||
results: response?.results ?? [], | ||
status: 'success', | ||
totalResults: response?.totalResults ?? 0 | ||
//cache: persistInCache ?? false | ||
}); | ||
}) | ||
.catch(error => { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
commit('setStatus', { query, status: 'error' }); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.