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/dragscrollclickfix.ts | 3 +-- viewer/src/services/indexfactory.ts | 21 ++++++++++++++++----- viewer/src/services/indexsearch.ts | 1 - viewer/src/services/ldzoom.ts | 6 ++++-- viewer/src/services/navigation.ts | 24 +++++++++++------------- 5 files changed, 32 insertions(+), 23 deletions(-) (limited to 'viewer/src/services') diff --git a/viewer/src/services/dragscrollclickfix.ts b/viewer/src/services/dragscrollclickfix.ts index 38eb106..7125510 100644 --- a/viewer/src/services/dragscrollclickfix.ts +++ b/viewer/src/services/dragscrollclickfix.ts @@ -19,7 +19,6 @@ // https://github.com/donmbelembe/vue-dragscroll/issues/61 export default class DragScrollClickFix { - readonly DRAG_DELAY = 250; // This is the minimal delay to consider a click to be a drag, mostly usefull for touch devices timer: NodeJS.Timeout | null = null; @@ -39,7 +38,7 @@ export default class DragScrollClickFix { clearTimeout(this.timer); this.timer = null; } - setTimeout(() => this.dragging = false); + setTimeout(() => (this.dragging = false)); } onClickCapture(e: MouseEvent) { 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); } // --- diff --git a/viewer/src/services/indexsearch.ts b/viewer/src/services/indexsearch.ts index a55a829..e6d7eed 100644 --- a/viewer/src/services/indexsearch.ts +++ b/viewer/src/services/indexsearch.ts @@ -20,7 +20,6 @@ import { Operation } from "@/@types/Operation"; export default class IndexSearch { - // Results of the search (by tags) public static search(searchTags: Tag.Search[]): Gallery.Item[] { const byOperation = this.extractTagsByOperation(searchTags); diff --git a/viewer/src/services/ldzoom.ts b/viewer/src/services/ldzoom.ts index ddf57c0..22d4699 100644 --- a/viewer/src/services/ldzoom.ts +++ b/viewer/src/services/ldzoom.ts @@ -33,9 +33,11 @@ export default class LdZoom { scaleFactor: number = 0.0; constructor( - containerElement: HTMLDivElement, imageElement: HTMLImageElement, + containerElement: HTMLDivElement, + imageElement: HTMLImageElement, pictureProperties: Gallery.PictureProperties, - maxScaleFactor: number, scrollZoomSpeed: number + maxScaleFactor: number, + scrollZoomSpeed: number ) { this.containerElement = containerElement; this.imageElement = imageElement; diff --git a/viewer/src/services/navigation.ts b/viewer/src/services/navigation.ts index a7e752c..5b0716d 100644 --- a/viewer/src/services/navigation.ts +++ b/viewer/src/services/navigation.ts @@ -20,6 +20,15 @@ import { ItemType } from "@/@types/ItemType"; export default class Navigation { + static readonly ICON_BY_TYPE: Record = { + directory: "folder", + picture: "image", + plaintext: "file-alt", + pdf: "file-pdf", + video: "file-video", + audio: "file-audio", + other: "file", + }; // Searches for an item by path from a root item (navigation) public static searchCurrentItemPath(root: Gallery.Item, path: string): Gallery.Item[] { @@ -61,25 +70,14 @@ export default class Navigation { .filter(child => Navigation.checkType(child, ItemType.DIRECTORY)) .sort((a, b) => a.title.localeCompare(b.title)), - ...items - .filter(child => !Navigation.checkType(child, ItemType.DIRECTORY)), + ...items.filter(child => !Navigation.checkType(child, ItemType.DIRECTORY)), ]; } // Get the icon for an item public static getIcon(item: Gallery.Item): string { if (item.path.length <= 1) return "home"; - switch (item.properties.type) { - case ItemType.PICTURE: return "image"; - case ItemType.PLAINTEXT: return "file-alt"; - case ItemType.PDF: return "file-pdf"; - case ItemType.VIDEO: return "file-video"; - case ItemType.AUDIO: return "file-audio"; - case ItemType.DIRECTORY: return "folder"; - case ItemType.OTHER: - default: - return "file"; - } + return Navigation.ICON_BY_TYPE[item.properties.type]; } // Get the file name of an item, without its cache timestamp -- cgit v1.2.3