fix: fix windows file upload because of path starting with a slash

This commit is contained in:
Jonathan Rainville 2020-09-29 16:41:26 -04:00 committed by Iuri Matias
parent 64b0a11757
commit f9a84c51bb
1 changed files with 10 additions and 2 deletions

View File

@ -214,9 +214,17 @@ QtObject:
self.messageList[chatId].resetTimeOut(messageId)
proc sendImage*(self: ChatsView, imagePath: string) {.slot.} =
let image = replace(imagePath, "file://", "")
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)
try:
self.status.chat.sendImage(self.activeChannel.id, tmpImagePath)
except Exception as e:
# TODO send error back to UI
error "Error sending the image", msg = e.msg
removeFile(tmpImagePath)
proc activeChannelChanged*(self: ChatsView) {.signal.}