aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/tools.ts
diff options
context:
space:
mode:
authorZero~Informatique2020-01-30 17:04:09 +0100
committerZero~Informatique2020-01-30 17:24:08 +0100
commit76af6cffce939ef3c9a0952e6f7adc234e92f782 (patch)
tree3b9ae6aa0f5b64b49c58904b670c9df34cbdd12e /viewer/src/tools.ts
parent234d0d13c767786393494810526a77d3d89b0e83 (diff)
downloadldgallery-76af6cffce939ef3c9a0952e6f7adc234e92f782.tar.gz
viewer: directories first and sorted by title in the navigation mode
Diffstat (limited to 'viewer/src/tools.ts')
-rw-r--r--viewer/src/tools.ts17
1 files changed, 17 insertions, 0 deletions
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 {
27 .toLowerCase(); 27 .toLowerCase();
28 } 28 }
29 29
30
31 public static checkType(item: Gallery.Item | null, type: Gallery.ItemType): boolean {
32 return item?.properties.type === type ?? false;
33 }
34
35 public static directoriesFirst(items: Gallery.Item[]) {
36 return [
37 ...items
38 .filter(child => Tools.checkType(child, "directory"))
39 .sort((a, b) => a.title.localeCompare(b.title)),
40
41 ...items
42 .filter(child => !Tools.checkType(child, "directory")),
43 ];
44 }
45
46
30} \ No newline at end of file 47} \ No newline at end of file