aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/services')
-rw-r--r--viewer/src/services/itemComparators.ts15
1 files changed, 12 insertions, 3 deletions
diff --git a/viewer/src/services/itemComparators.ts b/viewer/src/services/itemComparators.ts
index 6a7c81c..64ce288 100644
--- a/viewer/src/services/itemComparators.ts
+++ b/viewer/src/services/itemComparators.ts
@@ -27,7 +27,12 @@ export default class ItemComparators {
27 27
28 static readonly ITEM_SORTS: ItemSort[] = [ 28 static readonly ITEM_SORTS: ItemSort[] = [
29 { name: "name_asc", text: i18n.t("command.sort.byNameAsc"), fn: ItemComparators.sortByNameAsc }, 29 { name: "name_asc", text: i18n.t("command.sort.byNameAsc"), fn: ItemComparators.sortByNameAsc },
30 { name: "date_desc", text: i18n.t("command.sort.byDateDesc"), fn: ItemComparators.sortByDateDesc }, 30 { name: "date_asc", text: i18n.t("command.sort.byDateAsc"), fn: ItemComparators.sortByDateAsc },
31 {
32 name: "date_desc",
33 text: i18n.t("command.sort.byDateDesc"),
34 fn: ItemComparators.reverse(ItemComparators.sortByDateAsc),
35 },
31 ]; 36 ];
32 37
33 static sortByNameAsc(left: Gallery.Item, right: Gallery.Item): number { 38 static sortByNameAsc(left: Gallery.Item, right: Gallery.Item): number {
@@ -38,7 +43,11 @@ export default class ItemComparators {
38 }); 43 });
39 } 44 }
40 45
41 static sortByDateDesc(left: Gallery.Item, right: Gallery.Item): number { 46 static sortByDateAsc(left: Gallery.Item, right: Gallery.Item): number {
42 return -left.datetime.localeCompare(right.datetime); // TODO: handle timezones 47 return left.datetime.localeCompare(right.datetime); // TODO: handle timezones
48 }
49
50 static reverse(fn: ItemComparator): ItemComparator {
51 return (l, r) => -fn(l, r);
43 } 52 }
44} 53}