From ebdc776237f37d532e1d4317d325da2324a8b975 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Mon, 7 Nov 2022 04:43:01 -0800 Subject: [PATCH] Fix refresh of photo on edit --- src/components/ImageEditor.vue | 1 + src/components/Viewer.vue | 13 +++++++++++++ src/components/frame/Photo.vue | 6 ++++++ src/services/dav/download.ts | 4 ++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/ImageEditor.vue b/src/components/ImageEditor.vue index 9d52fc72..19f6efa4 100644 --- a/src/components/ImageEditor.vue +++ b/src/components/ImageEditor.vue @@ -178,6 +178,7 @@ export default class ImageEditor extends Mixins(GlobalMixin) { } else { emit("files:file:updated", { fileid: this.fileid }); } + this.onClose(undefined, false); } catch (error) { showError(this.t("viewer", "Error saving image")); } diff --git a/src/components/Viewer.vue b/src/components/Viewer.vue index 29641f44..882c92db 100644 --- a/src/components/Viewer.vue +++ b/src/components/Viewer.vue @@ -172,11 +172,15 @@ export default class Viewer extends Mixins(GlobalMixin) { mounted() { subscribe("files:sidebar:opened", this.handleAppSidebarOpen); subscribe("files:sidebar:closed", this.handleAppSidebarClose); + subscribe("files:file:created", this.handleFileUpdated); + subscribe("files:file:updated", this.handleFileUpdated); } beforeDestroy() { unsubscribe("files:sidebar:opened", this.handleAppSidebarOpen); unsubscribe("files:sidebar:closed", this.handleAppSidebarClose); + unsubscribe("files:file:created", this.handleFileUpdated); + unsubscribe("files:file:updated", this.handleFileUpdated); } /** Number of buttons to show inline */ @@ -224,6 +228,15 @@ export default class Viewer extends Mixins(GlobalMixin) { : null; } + /** Event on file changed */ + handleFileUpdated({ fileid }: { fileid: number }) { + console.log("file updated", fileid); + if (this.currentPhoto && this.currentPhoto.fileid === fileid) { + this.currentPhoto.etag += "_"; + this.photoswipe.refreshSlideContent(this.currIndex); + } + } + /** Create the base photoswipe object */ private async createBase(args: PhotoSwipeOptions) { this.show = true; diff --git a/src/components/frame/Photo.vue b/src/components/frame/Photo.vue index 286f01f5..27b451e5 100644 --- a/src/components/frame/Photo.vue +++ b/src/components/frame/Photo.vue @@ -79,6 +79,12 @@ export default class Photo extends Mixins(GlobalMixin) { } } + @Watch("data.etag") + onEtagChange() { + this.hasFaceRect = false; + this.refresh(); + } + mounted() { this.hasFaceRect = false; this.refresh(); diff --git a/src/services/dav/download.ts b/src/services/dav/download.ts index fa116a99..48d0d7c7 100644 --- a/src/services/dav/download.ts +++ b/src/services/dav/download.ts @@ -98,9 +98,9 @@ export function getDownloadLink(photo: IPhoto) { route.params.name ); if (fInfos.length) { - return `/remote.php/dav/${fInfos[0].originalFilename}`; + return `/remote.php/dav${fInfos[0].originalFilename}`; } } - return `/remote.php/dav/${photo.filename}`; // normal route + return `/remote.php/dav${photo.filename}`; // normal route }