diff options
Diffstat (limited to 'viewer/src/tools.ts')
-rw-r--r-- | viewer/src/tools.ts | 17 |
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 |