From e6c2a8d9653ffde924632ca2f260c3a8cddc14ed Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 11 Sep 2020 00:15:04 +0200 Subject: viewer: item display order github: resolves #28 --- viewer/src/store/galleryStore.ts | 4 ++-- viewer/src/store/uiStore.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'viewer/src/store') 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 { galleryIndex: Gallery.Index | null = null; tagsIndex: Tag.Index = {}; tagsCategories: Tag.Category[] = []; - currentPath: string = "/"; + currentPath: string | null = null; currentSearch: Tag.Search[] = []; // --- @@ -64,7 +64,7 @@ export default class GalleryStore extends VuexModule { get currentItemPath(): Gallery.Item[] { const root = this.galleryIndex?.tree; - if (root) return Navigation.searchCurrentItemPath(root, this.currentPath); + if (root && this.currentPath) return Navigation.searchCurrentItemPath(root, this.currentPath); return []; } 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 @@ */ import { createModule, mutation, action } from "vuex-class-component"; +import ItemSortFn from "@/services/itemSortFn"; const VuexModule = createModule({ namespaced: "uiStore", strict: true, }); +type TItemSortFn = (left: Gallery.Item, right: Gallery.Item) => number; + export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; + sortFn: TItemSortFn = ItemSortFn.sortByName; // --- @@ -42,4 +46,8 @@ export default class UIStore extends VuexModule { @mutation toggleSearchMode(value?: boolean) { this.searchMode = value ?? !this.searchMode; } + + @mutation setSortFn(sortFn: TItemSortFn) { + this.sortFn = sortFn; + } } -- cgit v1.2.3