From 4ccc31e6bf3fe76e660274c21ad3eb10aa6ee5be Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Fri, 26 Aug 2022 10:38:25 +0200 Subject: rename 'insert attachment' menu action, wait for metadata before resolving loadImage Signed-off-by: Julien Veyssier --- src/nodes/ImageView.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nodes/ImageView.vue') diff --git a/src/nodes/ImageView.vue b/src/nodes/ImageView.vue index 065482bfa..65d0a1790 100644 --- a/src/nodes/ImageView.vue +++ b/src/nodes/ImageView.vue @@ -251,13 +251,13 @@ export default { async loadImage(imageUrl, attachmentType, name = null) { return new Promise((resolve, reject) => { const img = new Image() - img.onload = () => { + img.onload = async () => { this.imageUrl = imageUrl this.imageLoaded = true this.loaded = true this.attachmentType = attachmentType if (attachmentType === this.$attachmentResolver.ATTACHMENT_TYPE_MEDIA) { - this.loadMediaMetadata(name) + await this.loadMediaMetadata(name) } resolve(imageUrl) } @@ -268,8 +268,10 @@ export default { }) }, loadMediaMetadata(name) { - this.$attachmentResolver.getMediaMetadata(name).then((response) => { + return this.$attachmentResolver.getMediaMetadata(name).then((response) => { this.attachmentMetadata = response.data + }).catch((error) => { + console.error(error) }) }, onImageLoadFailure(err) { -- cgit v1.2.3