From 7c184f35002886947493070400500e7e05de74b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Thu, 29 Aug 2024 17:36:38 +0200 Subject: [PATCH] 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 --- .../StatusChatImageExtensionValidator.qml | 6 +----- .../status/StatusChatImageQtyValidator.qml | 6 +----- .../status/StatusChatImageSizeValidator.qml | 2 +- ui/imports/shared/status/StatusChatInput.qml | 18 +++++++++++++----- ui/imports/utils/Constants.qml | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ui/imports/shared/status/StatusChatImageExtensionValidator.qml b/ui/imports/shared/status/StatusChatImageExtensionValidator.qml index 2b04f3ca60..a76d36c4cd 100644 --- a/ui/imports/shared/status/StatusChatImageExtensionValidator.qml +++ b/ui/imports/shared/status/StatusChatImageExtensionValidator.qml @@ -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 diff --git a/ui/imports/shared/status/StatusChatImageQtyValidator.qml b/ui/imports/shared/status/StatusChatImageQtyValidator.qml index 4b170a9b89..156dbf8e62 100644 --- a/ui/imports/shared/status/StatusChatImageQtyValidator.qml +++ b/ui/imports/shared/status/StatusChatImageQtyValidator.qml @@ -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 diff --git a/ui/imports/shared/status/StatusChatImageSizeValidator.qml b/ui/imports/shared/status/StatusChatImageSizeValidator.qml index b6c3af81ba..02fbabd9fd 100644 --- a/ui/imports/shared/status/StatusChatImageSizeValidator.qml +++ b/ui/imports/shared/status/StatusChatImageSizeValidator.qml @@ -1,4 +1,4 @@ -import QtQuick 2.13 +import QtQuick 2.15 import utils 1.0 diff --git a/ui/imports/shared/status/StatusChatInput.qml b/ui/imports/shared/status/StatusChatInput.qml index 3228c84332..a7b814a1a3 100644 --- a/ui/imports/shared/status/StatusChatInput.qml +++ b/ui/imports/shared/status/StatusChatInput.qml @@ -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) diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 66e52b9e61..aeaa97aa25 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -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