Skip to content

TagSpaces is an offline, open source, document manager with tagging support

adding notification by search

Ilian Sapundshieve24f7edd368e
diff --git a/app/reducers/app.js b/app/reducers/app.js
index 481e97121..c5441e6a5 100644
--- a/app/reducers/app.js
+++ b/app/reducers/app.js
@@ -264,13 +264,9 @@ export default (state: Object = initialState, action: Object) => {
return { ...state, isFileDragged: action.isFileDragged };
}
case types.INDEX_DIRECTORY_SEARCH: {
- const searchResults = Search.searchLocationIndex(
- state.currentDirectoryIndex,
- action.searchQuery
- );
return {
...state,
- currentDirectoryEntries: searchResults,
+ currentDirectoryEntries: action.searchResults,
isLoading: false
};
}
@@ -906,10 +902,22 @@ export const actions = {
},
startDirectoryIndexing: () => ({ type: types.INDEX_DIRECTORY_START }),
cancelDirectoryIndexing: () => ({ type: types.INDEX_DIRECTORY_CANCEL }),
- searchLocationIndex: (searchQuery: SearchQuery) => ({
+ searchLocationIndexFinished: (searchResults: Array<Object> | []) => ({
type: types.INDEX_DIRECTORY_SEARCH,
- searchQuery
+ searchResults
}),
+ searchLocationIndex: (searchQuery: SearchQuery) => (
+ dispatch: (actions: Object) => void,
+ getState: () => Object
+ ) => {
+ dispatch(actions.showNotification('Searching...!', 'default', false));
+ const searchResults = Search.searchLocationIndex(
+ getState().app.currentDirectoryIndex,
+ searchQuery
+ );
+ dispatch(actions.searchLocationIndexFinished(searchResults));
+ dispatch(actions.hideNotifications());
+ },
setCurrentLocationId: (locationId: string | null) => ({
type: types.SET_CURRENLOCATIONID,
locationId
diff --git a/app/services/search.js b/app/services/search.js
index 0ca9414b9..37f5c7e19 100644
--- a/app/services/search.js
+++ b/app/services/search.js
@@ -140,7 +140,7 @@ function constructFuseQuery(searchQuery: SearchQuery): string {
}
export default class Search {
- static searchLocationIndex(locationContent: Array<Object>, searchQuery: SearchQuery) {
+ static searchLocationIndex(locationContent: Array<Object>, searchQuery: SearchQuery): Array<Object> | [] {
// let result = jmespath.search({ index: locationContent }, "index[?contains(name, '" + searchQuery.textQuery + "')]");
// ?tags[?title=='todo' || title=='high'
// index[?extension=='png' || extension=='jpg']