fix(chat): chat input accepts DnD for blocked users

- do not allow DND when the StatusChatInput is disabled
- remove `Global.dragArea` variable from the Global singleton
- move the `DropAreaPanel` into `StatusChatInput` and handle its
enabling from there

Fixes #16451
This commit is contained in:
Lukáš Tinkl 2024-10-07 14:31:53 +02:00 committed by Anastasiya
parent 92d8d601e5
commit bf666c20f5
8 changed files with 14 additions and 42 deletions

View File

@ -32,7 +32,6 @@ SplitView {
}
Component.onCompleted: {
Utils.globalUtilsInst = globalUtilsMock.globalUtils
Global.dragArea = null
globalUtilsMock.ready = true
}
}

View File

@ -702,9 +702,5 @@ Item {
function isCompressedPubKey(publicKey) {
return false
}
Component.onCompleted: {
Global.dragArea = root
}
}
}

View File

@ -50,8 +50,6 @@ import mainui.activitycenter.popups 1.0
import SortFilterProxyModel 0.2
import "panels"
Item {
id: appMain
@ -1353,14 +1351,6 @@ Item {
ChatLayout {
id: chatLayoutContainer
Binding {
target: rootDropAreaPanel
property: "enabled"
value: chatLayoutContainer.currentIndex === 0 // Meaning: Chats / channels view
when: visible
restoreMode: Binding.RestoreBindingOrValue
}
sharedRootStore: appMain.sharedRootStore
rootStore: ChatStores.RootStore {
contactsStore: appMain.rootStore.contactStore
@ -1487,14 +1477,6 @@ Item {
readonly property bool isManageCommunityEnabledInAdvanced: appMain.rootStore.profileSectionStore.advancedStore.isManageCommunityOnTestModeEnabled
Binding {
target: rootDropAreaPanel
property: "enabled"
value: chatLayoutComponent.currentIndex === 0 // Meaning: Chats / channels view
when: visible
restoreMode: Binding.RestoreBindingOrValue
}
Connections {
target: Global
function onSwitchToCommunitySettings(communityId: string) {
@ -2153,13 +2135,6 @@ Item {
}
}
DropAreaPanel {
id: rootDropAreaPanel
width: appMain.width
height: appMain.height
}
Loader {
id: userAgreementLoader
active: production && !localAppSettings.testEnvironment

View File

@ -1,4 +1,5 @@
import QtQuick 2.14
import QtQuick 2.15
import utils 1.0
DropArea {
@ -13,10 +14,6 @@ DropArea {
rptDraggedPreviews.model = []
}
Component.onCompleted: {
Global.dragArea = this;
}
onDropped: (drop) => {
if (enabled) {
droppedOnValidScreen(drop)
@ -42,7 +39,7 @@ DropArea {
onExited: cleanup()
Loader {
active: root.containsDrag
active: root.containsDrag && root.enabled
width: active ? parent.width : 0
height: active ? parent.height : 0
sourceComponent: Rectangle {

View File

@ -2,3 +2,4 @@ AppMain 1.0 AppMain.qml
SplashScreen 1.0 SplashScreen.qml
Popups 1.0 Popups.qml
StatusTrayIcon 1.0 StatusTrayIcon.qml
DropAreaPanel 1.0 panels/DropAreaPanel.qml

View File

@ -1,8 +1,11 @@
import QtQuick 2.15
import QtQuick.Window 2.15
import QtGraphicalEffects 1.15
import shared.panels 1.0
import utils 1.0
Item {
id: root

View File

@ -11,6 +11,8 @@ import shared.panels 1.0
import shared.popups 1.0
import shared.stores 1.0 as SharedStores
import mainui 1.0
//TODO remove this dependency
import AppLayouts.Chat.panels 1.0
import AppLayouts.Chat.stores 1.0 as ChatStores
@ -948,11 +950,11 @@ Rectangle {
messageInputField.forceActiveFocus();
}
Connections {
target: Global.dragArea
enabled: control.visible
ignoreUnknownSignals: true
function onDroppedOnValidScreen(drop) {
DropAreaPanel {
enabled: control.visible && control.enabled
parent: Overlay.overlay
anchors.fill: parent
onDroppedOnValidScreen: (drop) => {
let dropUrls = drop.urls
if (!drop.hasUrls) {
console.warn("Trying to drop, list of URLs is empty tho; formats:", drop.formats)

View File

@ -5,7 +5,6 @@ import QtQml 2.15
QtObject {
id: root
property var dragArea
property bool activityPopupOpened: false
property int settingsSubsection: Constants.settingsSubsection.profile
property int settingsSubSubsection: -1