aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/store/uiStore.ts
diff options
context:
space:
mode:
authorZero~Informatique2020-09-12 22:33:37 +0200
committerG.Fouet2020-09-12 23:19:44 +0200
commitb909ec093591b50950c0de54b2005d471ca28116 (patch)
tree6fe72175022d4e39a44e9270865f611d2e819b05 /viewer/src/store/uiStore.ts
parent96ed5e6583a7f03d4ea7fa0512e66fffb656cc6e (diff)
downloadldgallery-b909ec093591b50950c0de54b2005d471ca28116.tar.gz
viewer: make default sort order configurable. code review improvements
github: resolves #239
Diffstat (limited to 'viewer/src/store/uiStore.ts')
-rw-r--r--viewer/src/store/uiStore.ts15
1 files changed, 5 insertions, 10 deletions
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts
index 04f14a0..84e7fed 100644
--- a/viewer/src/store/uiStore.ts
+++ b/viewer/src/store/uiStore.ts
@@ -29,7 +29,7 @@ export default class UIStore extends VuexModule {
29 fullscreen: boolean = false; 29 fullscreen: boolean = false;
30 fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); 30 fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT);
31 searchMode: boolean = false; 31 searchMode: boolean = false;
32 sortFn: ItemComparator = ItemComparators.sortByNameAsc; 32 sortFn: ItemComparator = ItemComparators.DEFAULT;
33 33
34 // --- 34 // ---
35 35
@@ -50,15 +50,10 @@ export default class UIStore extends VuexModule {
50 } 50 }
51 51
52 @action async initFromConfig(config: Gallery.Config) { 52 @action async initFromConfig(config: Gallery.Config) {
53 switch (config.initialSort ?? "") { 53 if (config.initialItemSort) {
54 case "date_desc": 54 const itemSort = ItemComparators.ITEM_SORTS.find(s => s.name == config.initialItemSort);
55 this.setSortFn(ItemComparators.sortByDateDesc); 55 if (itemSort) this.setSortFn(itemSort.fn);
56 break; 56 else throw new Error("Unknown sort type: " + config.initialItemSort);
57 case "name_asc":
58 case "":
59 break;
60 default:
61 throw new Error("Unknown sort type: " + config.initialSort);
62 } 57 }
63 } 58 }
64} 59}