diff options
Diffstat (limited to 'viewer/src/services/indexfactory.ts')
-rw-r--r-- | viewer/src/services/indexfactory.ts | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/viewer/src/services/indexfactory.ts b/viewer/src/services/indexfactory.ts index 00abc05..c4b6d51 100644 --- a/viewer/src/services/indexfactory.ts +++ b/viewer/src/services/indexfactory.ts | |||
@@ -22,7 +22,6 @@ import { ItemType } from "@/@types/ItemType"; | |||
22 | import Navigation from "@/services/navigation"; | 22 | import Navigation from "@/services/navigation"; |
23 | 23 | ||
24 | export default class IndexFactory { | 24 | export default class IndexFactory { |
25 | |||
26 | public static generateTags(root: Gallery.Item | null): Tag.Index { | 25 | public static generateTags(root: Gallery.Item | null): Tag.Index { |
27 | let tagsIndex: Tag.Index = {}; | 26 | let tagsIndex: Tag.Index = {}; |
28 | if (root) IndexFactory.pushTagsForItem(tagsIndex, root); | 27 | if (root) IndexFactory.pushTagsForItem(tagsIndex, root); |
@@ -51,7 +50,15 @@ export default class IndexFactory { | |||
51 | } | 50 | } |
52 | 51 | ||
53 | private static pushPartToIndex(index: Tag.Node, part: string, item: Gallery.Item, rootPart: boolean): Tag.Node { | 52 | private static pushPartToIndex(index: Tag.Node, part: string, item: Gallery.Item, rootPart: boolean): Tag.Node { |
54 | if (!index) index = { tag: part, tagfiltered: Navigation.normalize(part), rootPart, childPart: !rootPart, items: [], children: {} }; | 53 | if (!index) |
54 | index = { | ||
55 | tag: part, | ||
56 | tagfiltered: Navigation.normalize(part), | ||
57 | rootPart, | ||
58 | childPart: !rootPart, | ||
59 | items: [], | ||
60 | children: {}, | ||
61 | }; | ||
55 | else if (rootPart) index.rootPart = true; | 62 | else if (rootPart) index.rootPart = true; |
56 | else index.childPart = true; | 63 | else index.childPart = true; |
57 | 64 | ||
@@ -61,7 +68,6 @@ export default class IndexFactory { | |||
61 | 68 | ||
62 | // --- | 69 | // --- |
63 | 70 | ||
64 | |||
65 | public static searchTags(tagsIndex: Tag.Index, filter: string, strict: boolean): Tag.Search[] { | 71 | public static searchTags(tagsIndex: Tag.Index, filter: string, strict: boolean): Tag.Search[] { |
66 | let search: Tag.Search[] = []; | 72 | let search: Tag.Search[] = []; |
67 | if (tagsIndex && filter) { | 73 | if (tagsIndex && filter) { |
@@ -106,7 +112,12 @@ export default class IndexFactory { | |||
106 | ); | 112 | ); |
107 | } | 113 | } |
108 | 114 | ||
109 | private static searchTagsFromFilter(tagsIndex: Tag.Index, operation: Operation, filter: string, strict: boolean): Tag.Search[] { | 115 | private static searchTagsFromFilter( |
116 | tagsIndex: Tag.Index, | ||
117 | operation: Operation, | ||
118 | filter: string, | ||
119 | strict: boolean | ||
120 | ): Tag.Search[] { | ||
110 | filter = Navigation.normalize(filter); | 121 | filter = Navigation.normalize(filter); |
111 | return Object.values(tagsIndex) | 122 | return Object.values(tagsIndex) |
112 | .filter(node => IndexFactory.matches(node, filter, strict)) | 123 | .filter(node => IndexFactory.matches(node, filter, strict)) |
@@ -115,7 +126,7 @@ export default class IndexFactory { | |||
115 | 126 | ||
116 | private static matches(node: Tag.Node, filter: string, strict: boolean): boolean { | 127 | private static matches(node: Tag.Node, filter: string, strict: boolean): boolean { |
117 | if (strict) return node.tagfiltered === filter; | 128 | if (strict) return node.tagfiltered === filter; |
118 | return node.tagfiltered.includes(filter) | 129 | return node.tagfiltered.includes(filter); |
119 | } | 130 | } |
120 | 131 | ||
121 | // --- | 132 | // --- |