From 76af6cffce939ef3c9a0952e6f7adc234e92f782 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 30 Jan 2020 17:04:09 +0100 Subject: viewer: directories first and sorted by title in the navigation mode --- viewer/src/tools.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'viewer/src/tools.ts') diff --git a/viewer/src/tools.ts b/viewer/src/tools.ts index 5eb287e..57a889d 100644 --- a/viewer/src/tools.ts +++ b/viewer/src/tools.ts @@ -27,4 +27,21 @@ export default class Tools { .toLowerCase(); } + + public static checkType(item: Gallery.Item | null, type: Gallery.ItemType): boolean { + return item?.properties.type === type ?? false; + } + + public static directoriesFirst(items: Gallery.Item[]) { + return [ + ...items + .filter(child => Tools.checkType(child, "directory")) + .sort((a, b) => a.title.localeCompare(b.title)), + + ...items + .filter(child => !Tools.checkType(child, "directory")), + ]; + } + + } \ No newline at end of file -- cgit v1.2.3