status-desktop/ui/imports/shared/status/StatusChatImageSizeValidator.qml
Lukáš Tinkl 42445d4b73 fix: App crashes on uploading an image containing "+" in its name
as we're dealing with local file URLs only here, we don't want to turn
the plus signs (`+`) into spaces (leads to failing to open the file,
emits an exception, crashes later on in our JS code)

Fixes #9538
2023-02-16 16:09:53 +01:00

21 lines
618 B
QML

import QtQuick 2.13
import utils 1.0
StatusChatImageValidator {
id: root
readonly property int maxImgSizeBytes: Constants.maxUploadFilesizeMB * 1048576 /* 1 MB in bytes */
onImagesChanged: {
let isValid = true
root.validImages = images.filter(img => {
let size = parseInt(globalUtils.getFileSize(img))
const isSmallEnough = size <= maxImgSizeBytes
isValid = isValid && isSmallEnough
return isSmallEnough
})
root.isValid = isValid
}
errorMessage: qsTr("Max image size is %1 MB").arg(Constants.maxUploadFilesizeMB)
}