From 26210d495aed813baac1095b5c7a7c7879d2d206 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 25 Sep 2020 10:42:33 +0200 Subject: viewer: refactor how the available sorts are stored github: resolves #259 --- viewer/src/store/uiStore.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 84e7fed..f065cdd 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -18,7 +18,7 @@ */ import { createModule, mutation, action } from "vuex-class-component"; -import ItemComparators, { ItemComparator } from "@/services/itemComparators"; +import ItemComparators, { ItemSort } from "@/services/itemComparators"; const VuexModule = createModule({ namespaced: "uiStore", @@ -29,7 +29,7 @@ export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; - sortFn: ItemComparator = ItemComparators.DEFAULT; + sort: ItemSort = ItemComparators.DEFAULT; // --- @@ -45,14 +45,14 @@ export default class UIStore extends VuexModule { this.searchMode = value ?? !this.searchMode; } - @mutation setSortFn(sortFn: ItemComparator) { - this.sortFn = sortFn; + @mutation setSort(sort: ItemSort) { + this.sort = sort; } @action async initFromConfig(config: Gallery.Config) { if (config.initialItemSort) { - const itemSort = ItemComparators.ITEM_SORTS.find(s => s.name == config.initialItemSort); - if (itemSort) this.setSortFn(itemSort.fn); + const itemSort = ItemComparators.ITEM_SORTS[config.initialItemSort]; + if (itemSort) this.setSort(itemSort); else throw new Error("Unknown sort type: " + config.initialItemSort); } } -- cgit v1.2.3