aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/store
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/store')
-rw-r--r--viewer/src/store/galleryStore.ts4
-rw-r--r--viewer/src/store/uiStore.ts8
2 files changed, 10 insertions, 2 deletions
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts
index 5458f20..768adb6 100644
--- a/viewer/src/store/galleryStore.ts
+++ b/viewer/src/store/galleryStore.ts
@@ -31,7 +31,7 @@ export default class GalleryStore extends VuexModule {
31 galleryIndex: Gallery.Index | null = null; 31 galleryIndex: Gallery.Index | null = null;
32 tagsIndex: Tag.Index = {}; 32 tagsIndex: Tag.Index = {};
33 tagsCategories: Tag.Category[] = []; 33 tagsCategories: Tag.Category[] = [];
34 currentPath: string = "/"; 34 currentPath: string | null = null;
35 currentSearch: Tag.Search[] = []; 35 currentSearch: Tag.Search[] = [];
36 36
37 // --- 37 // ---
@@ -64,7 +64,7 @@ export default class GalleryStore extends VuexModule {
64 64
65 get currentItemPath(): Gallery.Item[] { 65 get currentItemPath(): Gallery.Item[] {
66 const root = this.galleryIndex?.tree; 66 const root = this.galleryIndex?.tree;
67 if (root) return Navigation.searchCurrentItemPath(root, this.currentPath); 67 if (root && this.currentPath) return Navigation.searchCurrentItemPath(root, this.currentPath);
68 return []; 68 return [];
69 } 69 }
70 70
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts
index 91ac338..1fe9f49 100644
--- a/viewer/src/store/uiStore.ts
+++ b/viewer/src/store/uiStore.ts
@@ -18,16 +18,20 @@
18*/ 18*/
19 19
20import { createModule, mutation, action } from "vuex-class-component"; 20import { createModule, mutation, action } from "vuex-class-component";
21import ItemSortFn from "@/services/itemSortFn";
21 22
22const VuexModule = createModule({ 23const VuexModule = createModule({
23 namespaced: "uiStore", 24 namespaced: "uiStore",
24 strict: true, 25 strict: true,
25}); 26});
26 27
28type TItemSortFn = (left: Gallery.Item, right: Gallery.Item) => number;
29
27export default class UIStore extends VuexModule { 30export default class UIStore extends VuexModule {
28 fullscreen: boolean = false; 31 fullscreen: boolean = false;
29 fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); 32 fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT);
30 searchMode: boolean = false; 33 searchMode: boolean = false;
34 sortFn: TItemSortFn = ItemSortFn.sortByName;
31 35
32 // --- 36 // ---
33 37
@@ -42,4 +46,8 @@ export default class UIStore extends VuexModule {
42 @mutation toggleSearchMode(value?: boolean) { 46 @mutation toggleSearchMode(value?: boolean) {
43 this.searchMode = value ?? !this.searchMode; 47 this.searchMode = value ?? !this.searchMode;
44 } 48 }
49
50 @mutation setSortFn(sortFn: TItemSortFn) {
51 this.sortFn = sortFn;
52 }
45} 53}