TagSpaces is an offline, open source, document manager with tagging support
feat: enabling indexing switch for all kinds of searches
Ilian Sapundshievac3a8d3abb78
diff --git a/app/components/Search.tsx b/app/components/Search.tsxindex 347a5d115..8d01fb377 100644--- a/app/components/Search.tsx+++ b/app/components/Search.tsx@@ -526,23 +526,21 @@ class Search extends React.Component<Props, State> {</ToggleButtonGroup></FormControl><br />- {this.state.searchBoxing === 'global' && (- <FormControlLabel- control={- <Switch- title="By enabling this option, the search will deliver better results, but it could take longer"- checked={this.state.forceIndexing}- onChange={() =>- this.setState(prevState => ({- forceIndexing: !prevState.forceIndexing- }))- }- name="forceIndexing"- />- }- label="Force reindexing all locations"- />- )}+ <FormControlLabel+ title={i18n.t('core:enableIndexingBySearch')}+ control={+ <Switch+ checked={this.state.forceIndexing}+ onChange={() =>+ this.setState(prevState => ({+ forceIndexing: !prevState.forceIndexing+ }))+ }+ name="forceIndexing"+ />+ }+ label="Force reindexing all locations"+ /><FormControl className={classes.formControl} disabled={indexing}><TagsSelectplaceholderText={i18n.t('core:selectTags')}diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 628367a6d..544af8cfb 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -464,5 +464,6 @@"objectStorage": "Object Storage (Amazon S3, Minio)","objectStorageTitle": "Amazon S3 complient object storage","endpointURL": "Endpoint URL",+ "enableIndexingBySearch": "By enabling this option, the search will deliver better results, but it will take longer","-": "-"}diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.tsindex a591fb5e2..3416d57e3 100644--- a/app/reducers/location-index.ts+++ b/app/reducers/location-index.ts@@ -288,15 +288,47 @@ export const actions = {type: types.INDEX_DIRECTORY_CLEAR}),searchLocationIndex: (searchQuery: SearchQuery) => (- dispatch: (actions: Object) => void+ dispatch: (actions: Object) => void,+ getState: () => any) => {+ const state = getState();+ const currentLocation: Location = getLocation(+ state,+ state.app.currentLocationId+ );+ window.walkCanceled = false;+ if (!currentLocation) {+ dispatch(+ AppActions.showNotification(+ i18n.t('core:pleaseOpenLocation'),+ 'warning',+ true+ )+ );+ return;+ }dispatch(AppActions.showNotification(i18n.t('core:searching'), 'default', false));dispatch(actions.setSearchQuery(searchQuery));- window.walkCanceled = false;- setTimeout(() => {+ let directoryIndex = GlobalSearch.index;+ setTimeout(async () => {// Workaround used to show the start search notification+ if (searchQuery.forceIndexing) {+ const currentPath = currentLocation.paths[0];+ console.log('Start creating index for : ' + currentPath);+ directoryIndex = await createDirectoryIndex(+ currentPath,+ currentLocation.fullTextIndex+ );+ if (Pro && Pro.Indexer && Pro.Indexer.persistIndex) {+ Pro.Indexer.persistIndex(+ currentPath,+ directoryIndex,+ PlatformIO.getDirSeparator()+ );+ }+ }Search.searchLocationIndex(GlobalSearch.index, searchQuery).then(searchResults => {dispatch(AppActions.setSearchResults(searchResults));@@ -381,14 +413,17 @@ export const actions = {PlatformIO.getDirSeparator());}+ if (isCloudLocation) {+ PlatformIO.disableObjectStoreSupport();+ }return Search.searchLocationIndex(directoryIndex, searchQuery).then(searchResults => {searchResultCount += searchResults.length;dispatch(AppActions.appendSearchResults(searchResults));dispatch(AppActions.hideNotifications());- if (isCloudLocation) {- PlatformIO.disableObjectStoreSupport();- }+ // if (isCloudLocation) {+ // PlatformIO.disableObjectStoreSupport();+ // }return true;}).catch(() => {