diff options
author | OzoneGrif | 2020-01-31 02:26:12 +0100 |
---|---|---|
committer | GitHub | 2020-01-31 02:26:12 +0100 |
commit | d94b987463169b254ab69a79ddb58e5beccb0941 (patch) | |
tree | 51f66cdada6a8e920ba80a3aae76393e0127d825 /viewer/src/tools.ts | |
parent | 15c806adec22239096a910b92b49fcfb964815bd (diff) | |
parent | 2157b66f3ea43137391939992cac4dc901a4ac4e (diff) | |
download | ldgallery-d94b987463169b254ab69a79ddb58e5beccb0941.tar.gz |
Merge pull request #65 from pacien/oz-viewer
viewer improvements
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 |