mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 22:36:24 +00:00
42445d4b73
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
21 lines
618 B
QML
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)
|
|
}
|