TagSpaces is an offline, open source, document manager with tagging support
fixing various issues with the global search, removing duplicates from the global search results
Ilian Sapundshiev1d62528fffac
diff --git a/app/app.global.css b/app/app.global.cssindex 483620be4..83d2ed2a0 100644--- a/app/app.global.css+++ b/app/app.global.css@@ -17,8 +17,8 @@ div[tabindex='-1']:focus {border-bottom: 1px solid #e9e9e91a;}-/* Fix for icon of broken thumbnails */-img[alt]:after {+/* Fix for icon of broken thumbnails, disabled because does not work in list view */+/* img[alt]:after {display: block;position: absolute;top: 0;@@ -29,4 +29,4 @@ img[alt]:after {color: #fff;text-align: center;content: attr(alt);-}+} */diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 20801254f..927017a64 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -287,10 +287,15 @@ export default (state: any = initialState, action: any) => {};}case types.APPEND_SEARCH_RESULTS: {- const newDirEntries = [- ...state.currentDirectoryEntries,- ...action.searchResults- ];+ const newDirEntries = [...state.currentDirectoryEntries];+ for (let i = 0; i < action.searchResults.length; i += 1) {+ const index = newDirEntries.findIndex(+ entry => entry.path === action.searchResults[i].path+ );+ if (index === -1) {+ newDirEntries.push(action.searchResults[i]);+ }+ }return {...state,currentDirectoryEntries: newDirEntries,diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.tsindex 5bb9eacaf..41b642356 100644--- a/app/reducers/location-index.ts+++ b/app/reducers/location-index.ts@@ -490,13 +490,19 @@ export const actions = {);}console.log('Global search completed!');- if (currentLocation.type === locationType.TYPE_CLOUD) {+ if (+ currentLocation &&+ currentLocation.type === locationType.TYPE_CLOUD+ ) {PlatformIO.enableObjectStoreSupport(currentLocation);}return true;}).catch(e => {- if (currentLocation.type === locationType.TYPE_CLOUD) {+ if (+ currentLocation &&+ currentLocation.type === locationType.TYPE_CLOUD+ ) {PlatformIO.enableObjectStoreSupport(currentLocation);}console.timeEnd('globalSearch');diff --git a/app/services/search.ts b/app/services/search.tsindex 4bf175b5a..9e15793eb 100644--- a/app/services/search.ts+++ b/app/services/search.ts@@ -21,6 +21,7 @@ import Fuse from 'fuse.js';import jmespath from 'jmespath';import { Tag } from '../reducers/taglibrary';import { Pro } from '../pro';+import { FileSystemEntry } from './utils-io';// export type FileTypeGroups = 'images' | 'notes' | 'documents' | 'audio' | 'video' | 'archives';@@ -250,9 +251,9 @@ function prepareIndex(index: Array<Object>) {export default class Search {static searchLocationIndex = (- locationContent: Array<Object>,+ locationContent: Array<FileSystemEntry>,searchQuery: SearchQuery- ): Promise<Array<Object> | []> =>+ ): Promise<Array<FileSystemEntry> | []> =>new Promise(resolve => {console.time('searchtime');const jmespathQuery = constructjmespathQuery(searchQuery);