diff options
author | OzoneGrif | 2020-04-04 04:32:31 +0200 |
---|---|---|
committer | GitHub | 2020-04-04 04:32:31 +0200 |
commit | e3a1566aca42190d486ee73612b9275560e17aa1 (patch) | |
tree | 9df4e6be5dfa15a0d27024d6857845014d84f96d /viewer/src/store | |
parent | f391a682dbd725c1d8aba9c571472bd390bb6a8d (diff) | |
parent | c26ab69997d1d552fda72b8fd88d5910fc91b779 (diff) | |
download | ldgallery-e3a1566aca42190d486ee73612b9275560e17aa1.tar.gz |
Merge branch 'develop' into oz-overflowing-titles
Diffstat (limited to 'viewer/src/store')
-rw-r--r-- | viewer/src/store/galleryStore.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 4a5de0f..352a266 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts | |||
@@ -31,6 +31,7 @@ export default class GalleryStore extends VuexModule { | |||
31 | config: Gallery.Config | null = null; | 31 | config: Gallery.Config | null = null; |
32 | galleryIndex: Gallery.Index | null = null; | 32 | galleryIndex: Gallery.Index | null = null; |
33 | tagsIndex: Tag.Index = {}; | 33 | tagsIndex: Tag.Index = {}; |
34 | tagsCategories: Tag.Category[] = []; | ||
34 | currentPath: string = "/"; | 35 | currentPath: string = "/"; |
35 | currentSearch: Tag.Search[] = []; | 36 | currentSearch: Tag.Search[] = []; |
36 | 37 | ||
@@ -48,6 +49,10 @@ export default class GalleryStore extends VuexModule { | |||
48 | this.tagsIndex = Object.freeze(tagsIndex); | 49 | this.tagsIndex = Object.freeze(tagsIndex); |
49 | } | 50 | } |
50 | 51 | ||
52 | @mutation private setTagsCategories(tagsCategories: Tag.Category[]) { | ||
53 | this.tagsCategories = tagsCategories; | ||
54 | } | ||
55 | |||
51 | @mutation setCurrentPath(currentPath: string) { | 56 | @mutation setCurrentPath(currentPath: string) { |
52 | this.currentPath = currentPath; | 57 | this.currentPath = currentPath; |
53 | } | 58 | } |
@@ -89,7 +94,8 @@ export default class GalleryStore extends VuexModule { | |||
89 | return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) | 94 | return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) |
90 | .then(response => response.json()) | 95 | .then(response => response.json()) |
91 | .then(this.setGalleryIndex) | 96 | .then(this.setGalleryIndex) |
92 | .then(this.indexTags); | 97 | .then(this.indexTags) |
98 | .then(this.indexTagCategories); | ||
93 | } | 99 | } |
94 | 100 | ||
95 | // Indexes the gallery | 101 | // Indexes the gallery |
@@ -100,6 +106,13 @@ export default class GalleryStore extends VuexModule { | |||
100 | return index; | 106 | return index; |
101 | } | 107 | } |
102 | 108 | ||
109 | // Indexes the proposed categories | ||
110 | @action async indexTagCategories() { | ||
111 | const categories = IndexFactory.generateCategories(this.tagsIndex, this.galleryIndex?.properties.tagCategories); | ||
112 | this.setTagsCategories(categories); | ||
113 | return categories; | ||
114 | } | ||
115 | |||
103 | // Searches for tags | 116 | // Searches for tags |
104 | @action async search(filters: string[]) { | 117 | @action async search(filters: string[]) { |
105 | const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); | 118 | const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); |