diff options
author | Zero~Informatique | 2020-02-28 04:09:40 +0100 |
---|---|---|
committer | Zero~Informatique | 2020-02-28 04:09:40 +0100 |
commit | 8d889762872501eebd5edb5d7cacddfd4cd55ad4 (patch) | |
tree | 984ceda461f5dc5294653f8edac3ef125b516159 /viewer/src/services | |
parent | afa8a533ebb6943405cc5933167634c144e7f8c7 (diff) | |
download | ldgallery-8d889762872501eebd5edb5d7cacddfd4cd55ad4.tar.gz |
viewer: more minor architectural improvement
Diffstat (limited to 'viewer/src/services')
-rw-r--r-- | viewer/src/services/indexfactory.ts | 14 |
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 | } |