aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services/indexfactory.ts
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/services/indexfactory.ts')
-rw-r--r--viewer/src/services/indexfactory.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/viewer/src/services/indexfactory.ts b/viewer/src/services/indexfactory.ts
index 45abcd5..a31f3ef 100644
--- a/viewer/src/services/indexfactory.ts
+++ b/viewer/src/services/indexfactory.ts
@@ -93,12 +93,10 @@ export default class IndexFactory {
93 category = Navigation.normalize(category); 93 category = Navigation.normalize(category);
94 disambiguation = Navigation.normalize(disambiguation); 94 disambiguation = Navigation.normalize(disambiguation);
95 return Object.values(tagsIndex) 95 return Object.values(tagsIndex)
96 .filter(node => strict || node.tagfiltered.includes(category)) 96 .filter(node => IndexFactory.matches(node, category, strict))
97 .filter(node => !strict || node.tagfiltered === category)
98 .flatMap(node => 97 .flatMap(node =>
99 Object.values(node.children) 98 Object.values(node.children)
100 .filter(child => strict || child.tagfiltered.includes(disambiguation)) 99 .filter(child => IndexFactory.matches(child, disambiguation, strict))
101 .filter(child => !strict || child.tagfiltered === disambiguation)
102 .map(child => ({ ...child, parent: node, operation, display: `${operation}${node.tag}:${child.tag}` })) 100 .map(child => ({ ...child, parent: node, operation, display: `${operation}${node.tag}:${child.tag}` }))
103 ); 101 );
104 } 102 }
@@ -106,8 +104,12 @@ export default class IndexFactory {
106 private static searchTagsFromFilter(tagsIndex: Tag.Index, operation: Operation, filter: string, strict: boolean): Tag.Search[] { 104 private static searchTagsFromFilter(tagsIndex: Tag.Index, operation: Operation, filter: string, strict: boolean): Tag.Search[] {
107 filter = Navigation.normalize(filter); 105 filter = Navigation.normalize(filter);
108 return Object.values(tagsIndex) 106 return Object.values(tagsIndex)
109 .filter(node => strict || node.tagfiltered.includes(filter)) 107 .filter(node => IndexFactory.matches(node, filter, strict))
110 .filter(node => !strict || node.tagfiltered === filter)
111 .map(node => ({ ...node, operation, display: `${operation}${node.tag}` })); 108 .map(node => ({ ...node, operation, display: `${operation}${node.tag}` }));
112 } 109 }
110
111 private static matches(node: Tag.Node, filter: string, strict: boolean): boolean {
112 if (strict) return node.tagfiltered === filter;
113 return node.tagfiltered.includes(filter)
114 }
113} 115}