From c3f5bb5518ee545e6397d85ce6da5abc8f3b9be9 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 14 Jul 2023 17:52:35 +0200 Subject: [PATCH] image note should reload after uploading new revision --- src/public/app/widgets/ribbon_widgets/image_properties.js | 2 +- src/public/app/widgets/type_widgets/image.js | 8 +++++++- src/public/app/widgets/type_widgets/type_widget.js | 8 ++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/public/app/widgets/ribbon_widgets/image_properties.js b/src/public/app/widgets/ribbon_widgets/image_properties.js index a15f61d35..064139bb0 100644 --- a/src/public/app/widgets/ribbon_widgets/image_properties.js +++ b/src/public/app/widgets/ribbon_widgets/image_properties.js @@ -49,7 +49,7 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget { return this.note && this.note.type === 'image'; } - getTitle(note) { + getTitle() { return { show: this.isEnabled(), activate: true, diff --git a/src/public/app/widgets/type_widgets/image.js b/src/public/app/widgets/type_widgets/image.js index 53c8e3ba1..6bfac7f77 100644 --- a/src/public/app/widgets/type_widgets/image.js +++ b/src/public/app/widgets/type_widgets/image.js @@ -90,7 +90,7 @@ class ImageTypeWidget extends TypeWidget { } async doRefresh(note) { - this.$imageView.prop("src", `api/images/${note.noteId}/${encodeURIComponent(note.title)}`); + this.$imageView.prop("src", `api/images/${note.noteId}/${encodeURIComponent(note.title)}?timestamp=${Date.now()}`); } copyImageReferenceToClipboardEvent({ntxId}) { @@ -100,6 +100,12 @@ class ImageTypeWidget extends TypeWidget { imageService.copyImageReferenceToClipboard(this.$imageWrapper); } + + async entitiesReloadedEvent({loadResults}) { + if (loadResults.isNoteReloaded(this.noteId)) { + this.refresh(); + } + } } export default ImageTypeWidget diff --git a/src/public/app/widgets/type_widgets/type_widget.js b/src/public/app/widgets/type_widgets/type_widget.js index 2d8f2e9fe..de328906f 100644 --- a/src/public/app/widgets/type_widgets/type_widget.js +++ b/src/public/app/widgets/type_widgets/type_widget.js @@ -11,9 +11,7 @@ export default class TypeWidget extends NoteContextAwareWidget { return super.doRender(); } - /** - * @param {FNote} note - */ + /** @param {FNote} note */ async doRefresh(note) {} async refresh() { @@ -38,9 +36,7 @@ export default class TypeWidget extends NoteContextAwareWidget { return this.$widget.is(":visible") && this.noteContext?.ntxId === appContext.tabManager.activeNtxId; } - /** - * @returns {Promise|*} promise resolving note data. Note data is an object with content. - */ + /** @returns {Promise|*} promise resolving note data. Note data is an object with content. */ getData() {} focus() {}