mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 14:26:34 +00:00
feat: show the error when sendImage fails
Plus improve toastMessage to better handle wide messages
This commit is contained in:
parent
f9a84c51bb
commit
8bac59e98c
@ -1,4 +1,4 @@
|
||||
import NimQml, Tables, json, sequtils, chronicles, times, re, sugar, strutils, os, sets
|
||||
import NimQml, Tables, json, sequtils, chronicles, times, re, sugar, strutils, os, sets, strformat
|
||||
import ../../status/status
|
||||
import ../../status/mailservers
|
||||
import ../../status/stickers
|
||||
@ -213,19 +213,19 @@ QtObject:
|
||||
self.status.chat.resendMessage(messageId)
|
||||
self.messageList[chatId].resetTimeOut(messageId)
|
||||
|
||||
proc sendImage*(self: ChatsView, imagePath: string) {.slot.} =
|
||||
var image: string = replace(imagePath, "file://", "")
|
||||
if defined(windows):
|
||||
# Windows doesn't work with paths starting with a slash
|
||||
image.removePrefix('/')
|
||||
let tmpImagePath = image_resizer(image, 2000, TMPDIR)
|
||||
proc sendImage*(self: ChatsView, imagePath: string): string {.slot.} =
|
||||
result = ""
|
||||
try:
|
||||
var image: string = replace(imagePath, "file://", "")
|
||||
if defined(windows):
|
||||
# Windows doesn't work with paths starting with a slash
|
||||
image.removePrefix('/')
|
||||
let tmpImagePath = image_resizer(image, 2000, TMPDIR)
|
||||
self.status.chat.sendImage(self.activeChannel.id, tmpImagePath)
|
||||
removeFile(tmpImagePath)
|
||||
except Exception as e:
|
||||
# TODO send error back to UI
|
||||
error "Error sending the image", msg = e.msg
|
||||
|
||||
removeFile(tmpImagePath)
|
||||
result = fmt"Error sending the image: {e.msg}"
|
||||
|
||||
proc activeChannelChanged*(self: ChatsView) {.signal.}
|
||||
|
||||
|
@ -47,7 +47,14 @@ Rectangle {
|
||||
|
||||
function sendMsg(event){
|
||||
if(chatColumn.isImage){
|
||||
chatsModel.sendImage(sendImageArea.image);
|
||||
const error = chatsModel.sendImage(sendImageArea.image);
|
||||
if (error) {
|
||||
toastMessage.title = error
|
||||
toastMessage.source = "../../../img/block-icon.svg"
|
||||
toastMessage.iconColor = Style.current.danger
|
||||
toastMessage.linkText = ""
|
||||
toastMessage.open()
|
||||
}
|
||||
}
|
||||
var msg = chatsModel.plainText(Emoji.deparse(txtData.text).trim()).trim()
|
||||
if(msg.length > 0){
|
||||
|
@ -19,7 +19,7 @@ Popup {
|
||||
height: 68
|
||||
padding: 0
|
||||
margins: 0
|
||||
width: 343
|
||||
width: Math.Max(Math.max(titleText.width, linkText.width) + toastImage.width + 12 * 4, 343)
|
||||
x: parent.width - width - Style.current.bigPadding
|
||||
y: parent.height - height - Style.current.bigPadding
|
||||
|
||||
@ -87,6 +87,7 @@ Popup {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: linkText
|
||||
text: qsTr(`<a href="%1" style="color:${Style.current.textColorTertiary};text-decoration:none;">%2</a>`)
|
||||
.arg(root.link)
|
||||
.arg(root.linkText)
|
||||
|
Loading…
x
Reference in New Issue
Block a user