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.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/viewer/src/services/indexfactory.ts b/viewer/src/services/indexfactory.ts
index 4b28a60..0c5fdc5 100644
--- a/viewer/src/services/indexfactory.ts
+++ b/viewer/src/services/indexfactory.ts
@@ -17,19 +17,20 @@
17-- along with this program. If not, see <https://www.gnu.org/licenses/>. 17-- along with this program. If not, see <https://www.gnu.org/licenses/>.
18*/ 18*/
19 19
20import { Operation } from "@/@types/Operation"; 20import { Item, RawTag } from "@/@types/gallery";
21import { ItemType } from "@/@types/ItemType"; 21import { ItemType } from "@/@types/ItemType";
22import { Operation } from "@/@types/Operation";
22import Navigation from "@/services/navigation"; 23import Navigation from "@/services/navigation";
23 24
24export default class IndexFactory { 25export default class IndexFactory {
25 public static generateTags(root: Gallery.Item | null): Tag.Index { 26 public static generateTags(root: Item | null): Tag.Index {
26 const tagsIndex: Tag.Index = {}; 27 const tagsIndex: Tag.Index = {};
27 if (root) IndexFactory.pushTagsForItem(tagsIndex, root); 28 if (root) IndexFactory.pushTagsForItem(tagsIndex, root);
28 return tagsIndex; 29 return tagsIndex;
29 } 30 }
30 31
31 // Pushes all tags for a root item (and its children) to the index 32 // Pushes all tags for a root item (and its children) to the index
32 private static pushTagsForItem(tagsIndex: Tag.Index, item: Gallery.Item): void { 33 private static pushTagsForItem(tagsIndex: Tag.Index, item: Item): void {
33 if (item.properties.type === ItemType.DIRECTORY) { 34 if (item.properties.type === ItemType.DIRECTORY) {
34 item.properties.items.forEach(item => this.pushTagsForItem(tagsIndex, item)); 35 item.properties.items.forEach(item => this.pushTagsForItem(tagsIndex, item));
35 return; // Directories are not indexed 36 return; // Directories are not indexed
@@ -49,7 +50,7 @@ export default class IndexFactory {
49 } 50 }
50 } 51 }
51 52
52 private static pushPartToIndex(index: Tag.Node, part: string, item: Gallery.Item, rootPart: boolean): Tag.Node { 53 private static pushPartToIndex(index: Tag.Node, part: string, item: Item, rootPart: boolean): Tag.Node {
53 if (!index) 54 if (!index)
54 index = { 55 index = {
55 tag: part, 56 tag: part,
@@ -131,7 +132,7 @@ export default class IndexFactory {
131 132
132 // --- 133 // ---
133 134
134 public static generateCategories(tagsIndex: Tag.Index, categoryTags?: Gallery.RawTag[]): Tag.Category[] { 135 public static generateCategories(tagsIndex: Tag.Index, categoryTags?: RawTag[]): Tag.Category[] {
135 if (!categoryTags?.length) return [{ tag: "", index: tagsIndex }]; 136 if (!categoryTags?.length) return [{ tag: "", index: tagsIndex }];
136 137
137 const tagsCategories: Tag.Category[] = []; 138 const tagsCategories: Tag.Category[] = [];
@@ -149,7 +150,7 @@ export default class IndexFactory {
149 return tagsCategories; 150 return tagsCategories;
150 } 151 }
151 152
152 private static isDiscriminantTagOnly(tags: Gallery.RawTag[], node: Tag.Node): boolean { 153 private static isDiscriminantTagOnly(tags: RawTag[], node: Tag.Node): boolean {
153 return !tags.includes(node.tag) || !node.childPart; 154 return !tags.includes(node.tag) || !node.childPart;
154 } 155 }
155} 156}