aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/services')
-rw-r--r--viewer/src/services/itemComparators.ts17
1 files changed, 7 insertions, 10 deletions
diff --git a/viewer/src/services/itemComparators.ts b/viewer/src/services/itemComparators.ts
index 82757ca..bd9accb 100644
--- a/viewer/src/services/itemComparators.ts
+++ b/viewer/src/services/itemComparators.ts
@@ -20,28 +20,25 @@ import { TranslateResult } from "vue-i18n";
20import i18n from "@/plugins/i18n"; 20import i18n from "@/plugins/i18n";
21 21
22export type ItemComparator = (left: Gallery.Item, right: Gallery.Item) => number; 22export type ItemComparator = (left: Gallery.Item, right: Gallery.Item) => number;
23export type ItemSort = { name: Gallery.ItemSortStr; text: TranslateResult; fn: ItemComparator }; 23export type ItemSort = { text: TranslateResult; fn: ItemComparator };
24 24
25export default class ItemComparators { 25export default class ItemComparators {
26 static readonly ITEM_SORTS: ItemSort[] = [ 26 static readonly ITEM_SORTS: Record<Gallery.ItemSortStr, ItemSort> = {
27 { 27 title_asc: {
28 name: "title_asc",
29 text: i18n.t("command.sort.byTitleAsc"), 28 text: i18n.t("command.sort.byTitleAsc"),
30 fn: ItemComparators.chain(ItemComparators.sortByTitleAsc, ItemComparators.sortByPathAsc), 29 fn: ItemComparators.chain(ItemComparators.sortByTitleAsc, ItemComparators.sortByPathAsc),
31 }, 30 },
32 { 31 date_asc: {
33 name: "date_asc",
34 text: i18n.t("command.sort.byDateAsc"), 32 text: i18n.t("command.sort.byDateAsc"),
35 fn: ItemComparators.chain(ItemComparators.sortByDateAsc, ItemComparators.sortByPathAsc), 33 fn: ItemComparators.chain(ItemComparators.sortByDateAsc, ItemComparators.sortByPathAsc),
36 }, 34 },
37 { 35 date_desc: {
38 name: "date_desc",
39 text: i18n.t("command.sort.byDateDesc"), 36 text: i18n.t("command.sort.byDateDesc"),
40 fn: ItemComparators.reverse(ItemComparators.chain(ItemComparators.sortByDateAsc, ItemComparators.sortByPathAsc)), 37 fn: ItemComparators.reverse(ItemComparators.chain(ItemComparators.sortByDateAsc, ItemComparators.sortByPathAsc)),
41 }, 38 },
42 ]; 39 };
43 40
44 static readonly DEFAULT = ItemComparators.ITEM_SORTS[1].fn; 41 static readonly DEFAULT = ItemComparators.ITEM_SORTS.date_asc;
45 42
46 static sortByPathAsc(left: Gallery.Item, right: Gallery.Item): number { 43 static sortByPathAsc(left: Gallery.Item, right: Gallery.Item): number {
47 return left.path.localeCompare(right.path, undefined, { 44 return left.path.localeCompare(right.path, undefined, {