From 19d40a5ee98fb1f244612155acc559ff2f21bf6b Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Wed, 12 Feb 2020 00:09:34 +0100 Subject: viewer: implemented config.json Note: The DevServer needs to know when the file is from the App, or from the FileSystem. We use a tilde to make this separation. The tilde URL is declared in '.env.development' GitHub: Resolves #32 --- viewer/src/store/galleryStore.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 1c95fe7..bcd4bc9 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -27,12 +27,17 @@ const VuexModule = createModule({ export default class GalleryStore extends VuexModule { + config: Gallery.Config | null = null; galleryItemsRoot: Gallery.Item | null = null; tags: Tag.Index = {}; currentPath: string = "/"; // --- + @mutation setConfig(config: Gallery.Config) { + this.config = config; + } + @mutation setGalleryItemsRoot(galleryItemsRoot: Gallery.Item) { this.galleryItemsRoot = galleryItemsRoot; } @@ -59,9 +64,18 @@ export default class GalleryStore extends VuexModule { // --- + // Fetches the gallery's JSON config + @action async fetchConfig() { + return fetch(`${process.env.VUE_APP_DATA_URL}config.json`) + .then(config => config.json()) + .then(this.setConfig); + } + // Fetches the gallery's JSON metadata - @action async fetchGalleryItems(url: string) { - return fetch(url) + @action async fetchGalleryItems() { + const root = this.config?.galleryRoot ?? ''; + const timestamp = this.config?.generationTimestamp ?? 0; + return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json?${timestamp}`) .then(response => response.json()) .then(this.setGalleryItemsRoot) .then(this.indexTags); -- cgit v1.2.3 From 1763c8ce725098100618079553a9ec4f79386a5d Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 13 Feb 2020 17:44:34 +0100 Subject: viewer: no-cache for config.json and index.json --- viewer/src/store/galleryStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'viewer/src/store') diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index bcd4bc9..6f5f0ad 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -66,7 +66,7 @@ export default class GalleryStore extends VuexModule { // Fetches the gallery's JSON config @action async fetchConfig() { - return fetch(`${process.env.VUE_APP_DATA_URL}config.json`) + return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) .then(config => config.json()) .then(this.setConfig); } @@ -75,7 +75,7 @@ export default class GalleryStore extends VuexModule { @action async fetchGalleryItems() { const root = this.config?.galleryRoot ?? ''; const timestamp = this.config?.generationTimestamp ?? 0; - return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json?${timestamp}`) + return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) .then(response => response.json()) .then(this.setGalleryItemsRoot) .then(this.indexTags); -- cgit v1.2.3