aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/store/uiStore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/store/uiStore.ts')
-rw-r--r--viewer/src/store/uiStore.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts
index 892d35e..f065cdd 100644
--- a/viewer/src/store/uiStore.ts
+++ b/viewer/src/store/uiStore.ts
@@ -18,17 +18,18 @@
18*/ 18*/
19 19
20import { createModule, mutation, action } from "vuex-class-component"; 20import { createModule, mutation, action } from "vuex-class-component";
21import ItemComparators, { ItemSort } from "@/services/itemComparators";
21 22
22const VuexModule = createModule({ 23const VuexModule = createModule({
23 namespaced: "uiStore", 24 namespaced: "uiStore",
24 strict: true 25 strict: true,
25}) 26});
26 27
27export default class UIStore extends VuexModule { 28export default class UIStore extends VuexModule {
28
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 sort: ItemSort = ItemComparators.DEFAULT;
32 33
33 // --- 34 // ---
34 35
@@ -43,4 +44,16 @@ export default class UIStore extends VuexModule {
43 @mutation toggleSearchMode(value?: boolean) { 44 @mutation toggleSearchMode(value?: boolean) {
44 this.searchMode = value ?? !this.searchMode; 45 this.searchMode = value ?? !this.searchMode;
45 } 46 }
47
48 @mutation setSort(sort: ItemSort) {
49 this.sort = sort;
50 }
51
52 @action async initFromConfig(config: Gallery.Config) {
53 if (config.initialItemSort) {
54 const itemSort = ItemComparators.ITEM_SORTS[config.initialItemSort];
55 if (itemSort) this.setSort(itemSort);
56 else throw new Error("Unknown sort type: " + config.initialItemSort);
57 }
58 }
46} 59}