diff options
Diffstat (limited to 'viewer/src/store')
-rw-r--r-- | viewer/src/store/galleryStore.ts | 15 | ||||
-rw-r--r-- | viewer/src/store/index.ts | 7 | ||||
-rw-r--r-- | viewer/src/store/uiStore.ts | 5 |
3 files changed, 14 insertions, 13 deletions
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 6d64e12..3ef2036 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts | |||
@@ -17,9 +17,10 @@ | |||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | 17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | import { createModule, mutation, action } from "vuex-class-component"; | 20 | import { Config, Index, Item } from "@/@types/gallery"; |
21 | import IndexFactory from "@/services/indexfactory"; | 21 | import IndexFactory from "@/services/indexfactory"; |
22 | import Navigation from "@/services/navigation"; | 22 | import Navigation from "@/services/navigation"; |
23 | import { action, createModule, mutation } from "vuex-class-component"; | ||
23 | 24 | ||
24 | const VuexModule = createModule({ | 25 | const VuexModule = createModule({ |
25 | namespaced: "galleryStore", | 26 | namespaced: "galleryStore", |
@@ -27,8 +28,8 @@ const VuexModule = createModule({ | |||
27 | }); | 28 | }); |
28 | 29 | ||
29 | export default class GalleryStore extends VuexModule { | 30 | export default class GalleryStore extends VuexModule { |
30 | config: Gallery.Config | null = null; | 31 | config: Config | null = null; |
31 | galleryIndex: Gallery.Index | null = null; | 32 | galleryIndex: Index | null = null; |
32 | tagsIndex: Tag.Index = {}; | 33 | tagsIndex: Tag.Index = {}; |
33 | tagsCategories: Tag.Category[] = []; | 34 | tagsCategories: Tag.Category[] = []; |
34 | currentPath: string | null = null; | 35 | currentPath: string | null = null; |
@@ -36,11 +37,11 @@ export default class GalleryStore extends VuexModule { | |||
36 | 37 | ||
37 | // --- | 38 | // --- |
38 | 39 | ||
39 | @mutation private setConfig(config: Gallery.Config) { | 40 | @mutation private setConfig(config: Config) { |
40 | this.config = config; | 41 | this.config = config; |
41 | } | 42 | } |
42 | 43 | ||
43 | @mutation setGalleryIndex(galleryIndex: Gallery.Index) { | 44 | @mutation setGalleryIndex(galleryIndex: Index) { |
44 | this.galleryIndex = Object.freeze(galleryIndex); | 45 | this.galleryIndex = Object.freeze(galleryIndex); |
45 | } | 46 | } |
46 | 47 | ||
@@ -62,13 +63,13 @@ export default class GalleryStore extends VuexModule { | |||
62 | 63 | ||
63 | // --- | 64 | // --- |
64 | 65 | ||
65 | get currentItemPath(): Gallery.Item[] { | 66 | get currentItemPath(): Item[] { |
66 | const root = this.galleryIndex?.tree; | 67 | const root = this.galleryIndex?.tree; |
67 | if (root && this.currentPath) return Navigation.searchCurrentItemPath(root, this.currentPath); | 68 | if (root && this.currentPath) return Navigation.searchCurrentItemPath(root, this.currentPath); |
68 | return []; | 69 | return []; |
69 | } | 70 | } |
70 | 71 | ||
71 | get currentItem(): Gallery.Item | null { | 72 | get currentItem(): Item | null { |
72 | const path = this.currentItemPath; | 73 | const path = this.currentItemPath; |
73 | return path.length > 0 ? path[path.length - 1] : null; | 74 | return path.length > 0 ? path[path.length - 1] : null; |
74 | } | 75 | } |
diff --git a/viewer/src/store/index.ts b/viewer/src/store/index.ts index f86d66b..1f49589 100644 --- a/viewer/src/store/index.ts +++ b/viewer/src/store/index.ts | |||
@@ -17,12 +17,11 @@ | |||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | 17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | import GalleryStore from "@/store/galleryStore"; | ||
21 | import UIStore from "@/store/uiStore"; | ||
20 | import Vue from "vue"; | 22 | import Vue from "vue"; |
21 | import Vuex from "vuex"; | 23 | import Vuex from "vuex"; |
22 | import { extractVuexModule } from "vuex-class-component"; | 24 | import { createProxy, extractVuexModule } from "vuex-class-component"; |
23 | import { createProxy } from "vuex-class-component"; | ||
24 | import UIStore from "@/store/uiStore"; | ||
25 | import GalleryStore from "@/store/galleryStore"; | ||
26 | 25 | ||
27 | Vue.use(Vuex); | 26 | Vue.use(Vuex); |
28 | 27 | ||
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index f065cdd..f5bb898 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts | |||
@@ -17,8 +17,9 @@ | |||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | 17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | import { createModule, mutation, action } from "vuex-class-component"; | 20 | import { Config } from "@/@types/gallery"; |
21 | import ItemComparators, { ItemSort } from "@/services/itemComparators"; | 21 | import ItemComparators, { ItemSort } from "@/services/itemComparators"; |
22 | import { action, createModule, mutation } from "vuex-class-component"; | ||
22 | 23 | ||
23 | const VuexModule = createModule({ | 24 | const VuexModule = createModule({ |
24 | namespaced: "uiStore", | 25 | namespaced: "uiStore", |
@@ -49,7 +50,7 @@ export default class UIStore extends VuexModule { | |||
49 | this.sort = sort; | 50 | this.sort = sort; |
50 | } | 51 | } |
51 | 52 | ||
52 | @action async initFromConfig(config: Gallery.Config) { | 53 | @action async initFromConfig(config: Config) { |
53 | if (config.initialItemSort) { | 54 | if (config.initialItemSort) { |
54 | const itemSort = ItemComparators.ITEM_SORTS[config.initialItemSort]; | 55 | const itemSort = ItemComparators.ITEM_SORTS[config.initialItemSort]; |
55 | if (itemSort) this.setSort(itemSort); | 56 | if (itemSort) this.setSort(itemSort); |