From 4b9b93a873e408c4ddaa9dc5ebca91dd69caa91e Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Tue, 29 Mar 2022 00:16:56 +0200 Subject: [PATCH] fix(@desktop/chat): Downlaoding/Copying an image from chat crashes the app The issue was caused because the data being passed to the UI is now a URL and not image data. Added support to download/copy image by URL fixes #5194 --- src/app/global/utils.nim | 6 ++++++ ui/app/AppLayouts/Chat/stores/RootStore.qml | 8 ++++---- ui/imports/shared/views/chat/MessageContextMenuView.qml | 4 ++-- vendor/DOtherSide | 2 +- vendor/nimqml | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/app/global/utils.nim b/src/app/global/utils.nim index 1bbe28f9b3..1ebc982503 100644 --- a/src/app/global/utils.nim +++ b/src/app/global/utils.nim @@ -105,9 +105,15 @@ QtObject: proc copyImageToClipboard*(self: Utils, content: string) {.slot.} = setClipBoardImage(content) + proc copyImageToClipboardByUrl*(self: Utils, url: string) {.slot.} = + setClipBoardImageByUrl(url) + proc downloadImage*(self: Utils, content: string, path: string) {.slot.} = downloadImage(content, path) + proc downloadImageByUrl*(self: Utils, url: string, path: string) {.slot.} = + downloadImageByUrl(url, path) + proc generateQRCodeSVG*(self: Utils, text: string, border: int = 0): string = var qr0: array[0..qrcodegen_BUFFER_LEN_MAX, uint8] var tempBuffer: array[0..qrcodegen_BUFFER_LEN_MAX, uint8] diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index feb0a9f23e..0fb1ef3738 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -167,12 +167,12 @@ QtObject { globalUtilsInst.copyToClipboard(text) } - function copyImageToClipboard(content) { - globalUtilsInst.copyImageToClipboard(content) + function copyImageToClipboardByUrl(content) { + globalUtilsInst.copyImageToClipboardByUrl(content) } - function downloadImage(content, path) { - globalUtilsInst.downloadImage(content, path) + function downloadImageByUrl(url, path) { + globalUtilsInst.downloadImageByUrl(url, path) } function isCurrentUser(pubkey) { diff --git a/ui/imports/shared/views/chat/MessageContextMenuView.qml b/ui/imports/shared/views/chat/MessageContextMenuView.qml index e6e8a42df6..39c74d46de 100644 --- a/ui/imports/shared/views/chat/MessageContextMenuView.qml +++ b/ui/imports/shared/views/chat/MessageContextMenuView.qml @@ -141,7 +141,7 @@ StatusPopupMenu { text: qsTr("Copy image") onTriggered: { if (root.imageSource) { - root.store.copyImageToClipboard(root.imageSource) + root.store.copyImageToClipboardByUrl(root.imageSource) } root.close() } @@ -324,7 +324,7 @@ StatusPopupMenu { modality: Qt.NonModal onAccepted: { if (root.imageSource) { - root.store.downloadImage(root.imageSource, fileDialog.fileUrls) + root.store.downloadImageByUrl(root.imageSource, fileDialog.fileUrls) } fileDialog.close() } diff --git a/vendor/DOtherSide b/vendor/DOtherSide index 676b1d9bc8..7c9d386121 160000 --- a/vendor/DOtherSide +++ b/vendor/DOtherSide @@ -1 +1 @@ -Subproject commit 676b1d9bc8a3b0d6e87d10f0ac7b5deff626266f +Subproject commit 7c9d386121d18a2deb8943286a6980a62d1f7b91 diff --git a/vendor/nimqml b/vendor/nimqml index eb20a5ffb9..d1b79f8a4c 160000 --- a/vendor/nimqml +++ b/vendor/nimqml @@ -1 +1 @@ -Subproject commit eb20a5ffb964507e508bfaa120c71f7c81c5cf8e +Subproject commit d1b79f8a4c0d35e5b7accd4620c727dabfa0b223