Skip to content

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

Double tags in search results (#1355) fixing #1354

Stanimir879de6674c7c
diff --git a/app/services/search.ts b/app/services/search.ts
index 30c8881ac..7607b868a 100644
--- a/app/services/search.ts
+++ b/app/services/search.ts
@@ -19,7 +19,7 @@
import Fuse from 'fuse.js';
import jmespath from 'jmespath';
-import { Tag } from '../reducers/taglibrary';
+import { Tag } from '-/reducers/taglibrary';
import { Pro } from '../pro';
import { FileSystemEntry } from './utils-io';
@@ -235,7 +235,10 @@ function prepareIndex(index: Array<Object>) {
const tags = [...entry.tags];
if (tags && tags.length) {
tags.map(tag => {
- tag.title = tag.title.toLowerCase();
+ if (tag.title.toLowerCase() !== tag.title) {
+ tag.originTitle = tag.title;
+ tag.title = tag.title.toLowerCase();
+ }
return tag;
});
}
@@ -249,6 +252,20 @@ function prepareIndex(index: Array<Object>) {
return resultIndex;
}
+function setOriginTitle(results: Array<Object>) {
+ return results.map((entry: any) => {
+ if (entry.tags && entry.tags.length) {
+ entry.tags.map(tag => {
+ if (tag.originTitle) {
+ tag.title = tag.originTitle;
+ }
+ return tag;
+ });
+ }
+ return entry;
+ });
+}
+
export default class Search {
static searchLocationIndex = (
locationContent: Array<FileSystemEntry>,
@@ -312,7 +329,7 @@ export default class Search {
}
console.log('Results send: ' + results.length);
console.timeEnd('searchtime');
- resolve(results);
+ resolve(setOriginTitle(results));
return true;
}
results = [];