From 74c1c5e34787ac57299c8cbd874e9dcc56da406d Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 22 May 2020 04:14:48 +0200 Subject: viewer: Enumerated item types --- viewer/src/services/indexfactory.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'viewer/src/services/indexfactory.ts') diff --git a/viewer/src/services/indexfactory.ts b/viewer/src/services/indexfactory.ts index e402185..00abc05 100644 --- a/viewer/src/services/indexfactory.ts +++ b/viewer/src/services/indexfactory.ts @@ -18,6 +18,7 @@ */ import { Operation } from "@/@types/Operation"; +import { ItemType } from "@/@types/ItemType"; import Navigation from "@/services/navigation"; export default class IndexFactory { @@ -30,7 +31,7 @@ export default class IndexFactory { // Pushes all tags for a root item (and its children) to the index private static pushTagsForItem(tagsIndex: Tag.Index, item: Gallery.Item): void { - if (item.properties.type === "directory") { + if (item.properties.type === ItemType.DIRECTORY) { item.properties.items.forEach(item => this.pushTagsForItem(tagsIndex, item)); return; // Directories are not indexed } -- cgit v1.2.3 From 170d7a61f720ece9dc4b347b19f5a8213f1d8984 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 20 Jun 2020 16:50:49 +0200 Subject: viewer: prettier formatting based on eslint-prettier plugin --- viewer/src/services/indexfactory.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'viewer/src/services/indexfactory.ts') 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"; import Navigation from "@/services/navigation"; export default class IndexFactory { - public static generateTags(root: Gallery.Item | null): Tag.Index { let tagsIndex: Tag.Index = {}; if (root) IndexFactory.pushTagsForItem(tagsIndex, root); @@ -51,7 +50,15 @@ export default class IndexFactory { } private static pushPartToIndex(index: Tag.Node, part: string, item: Gallery.Item, rootPart: boolean): Tag.Node { - if (!index) index = { tag: part, tagfiltered: Navigation.normalize(part), rootPart, childPart: !rootPart, items: [], children: {} }; + if (!index) + index = { + tag: part, + tagfiltered: Navigation.normalize(part), + rootPart, + childPart: !rootPart, + items: [], + children: {}, + }; else if (rootPart) index.rootPart = true; else index.childPart = true; @@ -61,7 +68,6 @@ export default class IndexFactory { // --- - public static searchTags(tagsIndex: Tag.Index, filter: string, strict: boolean): Tag.Search[] { let search: Tag.Search[] = []; if (tagsIndex && filter) { @@ -106,7 +112,12 @@ export default class IndexFactory { ); } - private static searchTagsFromFilter(tagsIndex: Tag.Index, operation: Operation, filter: string, strict: boolean): Tag.Search[] { + private static searchTagsFromFilter( + tagsIndex: Tag.Index, + operation: Operation, + filter: string, + strict: boolean + ): Tag.Search[] { filter = Navigation.normalize(filter); return Object.values(tagsIndex) .filter(node => IndexFactory.matches(node, filter, strict)) @@ -115,7 +126,7 @@ export default class IndexFactory { private static matches(node: Tag.Node, filter: string, strict: boolean): boolean { if (strict) return node.tagfiltered === filter; - return node.tagfiltered.includes(filter) + return node.tagfiltered.includes(filter); } // --- -- cgit v1.2.3 From 303929136ca6446f538fcfc80ce26626c726f759 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sun, 28 Jun 2020 14:03:04 +0200 Subject: viewer: dependancies update --- viewer/src/services/indexfactory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'viewer/src/services/indexfactory.ts') diff --git a/viewer/src/services/indexfactory.ts b/viewer/src/services/indexfactory.ts index c4b6d51..4b28a60 100644 --- a/viewer/src/services/indexfactory.ts +++ b/viewer/src/services/indexfactory.ts @@ -23,7 +23,7 @@ import Navigation from "@/services/navigation"; export default class IndexFactory { public static generateTags(root: Gallery.Item | null): Tag.Index { - let tagsIndex: Tag.Index = {}; + const tagsIndex: Tag.Index = {}; if (root) IndexFactory.pushTagsForItem(tagsIndex, root); return tagsIndex; } -- cgit v1.2.3