fix(StatusChatInput): set max number of images to 6 to align with mobile

- re-evaluate the validators to be able to hide the warning after 3
seconds (the validators won't let the user select/paste an invalid
image; it's just the warning bubble that persisted)
- some small cleanups

Fixes #16210
This commit is contained in:
Lukáš Tinkl 2024-08-29 17:36:38 +02:00 committed by Lukáš Tinkl
parent 3c4eb3180d
commit 7c184f3500
5 changed files with 17 additions and 17 deletions

View File

@ -1,10 +1,6 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.0
import QtQuick 2.15
import utils 1.0
import ".."
StatusChatImageValidator {
id: root

View File

@ -1,10 +1,6 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.0
import QtQuick 2.15
import utils 1.0
import ".."
StatusChatImageValidator {
id: root

View File

@ -1,4 +1,4 @@
import QtQuick 2.13
import QtQuick 2.15
import utils 1.0

View File

@ -70,7 +70,7 @@ Rectangle {
property bool askToEnableLinkPreview: false
property var imageErrorMessageLocation: StatusChatInput.ImageErrorMessageLocation.Top // TODO: Remove this property?
property int imageErrorMessageLocation: StatusChatInput.ImageErrorMessageLocation.Top // TODO: Remove this property?
property alias suggestions: suggestionsBox
@ -880,10 +880,7 @@ Rectangle {
resetReplyArea()
}
function validateImages(imagePaths) {
if (!imagePaths || !imagePaths.length) {
return []
}
function validateImages(imagePaths = []) {
// needed because control.fileUrlsAndSources is not a normal js array
const existing = (control.fileUrlsAndSources || []).map(x => x.toString())
let validImages = Utils.deduplicate(existing.concat(imagePaths))
@ -1144,14 +1141,24 @@ Rectangle {
z: 1
StatusChatImageExtensionValidator {
id: imageExtValidator
Layout.alignment: Qt.AlignHCenter
}
StatusChatImageSizeValidator {
id: imageSizeValidator
Layout.alignment: Qt.AlignHCenter
}
StatusChatImageQtyValidator {
id: imageQtyValidator
Layout.alignment: Qt.AlignHCenter
}
Timer {
interval: 3000
repeat: true
running: !imageQtyValidator.isValid || !imageSizeValidator.isValid || !imageExtValidator.isValid
onTriggered: validateImages(control.fileUrlsAndSources)
}
}
Rectangle {
@ -1195,6 +1202,7 @@ Rectangle {
urls.splice(index, 1)
}
control.fileUrlsAndSources = urls
validateImages(control.fileUrlsAndSources)
}
onImageClicked: (chatImage) => Global.openImagePopup(chatImage, "", false)
onLinkReload: (link) => control.linkPreviewReloaded(link)

View File

@ -988,7 +988,7 @@ QtObject {
readonly property string statusHelpLinkPrefix: `https://status.app/help/`
readonly property string downloadLink: "https://status.im/get"
readonly property int maxUploadFiles: 5
readonly property int maxUploadFiles: 6
readonly property double maxUploadFilesizeMB: 10
readonly property int maxNumberOfPins: 3