aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services/navigation.ts
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/services/navigation.ts')
-rw-r--r--viewer/src/services/navigation.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/viewer/src/services/navigation.ts b/viewer/src/services/navigation.ts
index 77fa47a..fa17990 100644
--- a/viewer/src/services/navigation.ts
+++ b/viewer/src/services/navigation.ts
@@ -31,7 +31,6 @@ export default class Navigation {
31 return []; 31 return [];
32 } 32 }
33 33
34
35 // Normalize a string to lowercase, no-accents 34 // Normalize a string to lowercase, no-accents
36 public static normalize(value: string) { 35 public static normalize(value: string) {
37 return value 36 return value
@@ -40,11 +39,20 @@ export default class Navigation {
40 .toLowerCase(); 39 .toLowerCase();
41 } 40 }
42 41
43 42 // Checks if the type of an item matches
44 public static checkType(item: Gallery.Item | null, type: Gallery.ItemType): boolean { 43 public static checkType(item: Gallery.Item | null, type: Gallery.ItemType): boolean {
45 return item?.properties.type === type ?? false; 44 return item?.properties.type === type ?? false;
46 } 45 }
47 46
47 public static getLastDirectory(itemPath: Gallery.Item[]): Gallery.Directory {
48 for (let idx = itemPath.length - 1; idx >= 0; idx--) {
49 const item = itemPath[idx];
50 if (Navigation.checkType(item, "directory")) return item as Gallery.Directory;
51 }
52 throw new Error("No directory found");
53 }
54
55 // Sort a list of items, moving the directories to the beginning of the list
48 public static directoriesFirst(items: Gallery.Item[]) { 56 public static directoriesFirst(items: Gallery.Item[]) {
49 return [ 57 return [
50 ...items 58 ...items
@@ -56,6 +64,7 @@ export default class Navigation {
56 ]; 64 ];
57 } 65 }
58 66
67 // Get the icon for an item
59 public static getIcon(item: Gallery.Item): string { 68 public static getIcon(item: Gallery.Item): string {
60 if (item.path.length <= 1) return "home"; 69 if (item.path.length <= 1) return "home";
61 switch (item.properties.type) { 70 switch (item.properties.type) {