aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/store/galleryStore.ts
diff options
context:
space:
mode:
authorZero~Informatique2021-07-02 22:53:16 +0200
committerZero~Informatique2021-07-03 00:05:22 +0200
commit9165cc1efcf7791f78b61b2c51a9de651b1b09aa (patch)
tree111cfdc74ddaf7b19ff27508f16ab84694b27670 /viewer/src/store/galleryStore.ts
parent08ac32103fb5f8cca1861267dfd07a7c0d2faf62 (diff)
downloadldgallery-9165cc1efcf7791f78b61b2c51a9de651b1b09aa.tar.gz
viewer: types normalization - gallery.d.ts
GitHub: closes #301
Diffstat (limited to 'viewer/src/store/galleryStore.ts')
-rw-r--r--viewer/src/store/galleryStore.ts15
1 files changed, 8 insertions, 7 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
20import { createModule, mutation, action } from "vuex-class-component"; 20import { Config, Index, Item } from "@/@types/gallery";
21import IndexFactory from "@/services/indexfactory"; 21import IndexFactory from "@/services/indexfactory";
22import Navigation from "@/services/navigation"; 22import Navigation from "@/services/navigation";
23import { action, createModule, mutation } from "vuex-class-component";
23 24
24const VuexModule = createModule({ 25const VuexModule = createModule({
25 namespaced: "galleryStore", 26 namespaced: "galleryStore",
@@ -27,8 +28,8 @@ const VuexModule = createModule({
27}); 28});
28 29
29export default class GalleryStore extends VuexModule { 30export 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 }