From 0702919d199e5dbbe113e55edb964a1c1bf48216 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 30 Dec 2024 13:45:34 -0500 Subject: [PATCH] feat(group): enable updating the group members while sending a message Fixes #8349 When the member selector menu is open, sending a message adds/removes the members and then sends the message. Therefore, the new member will also receive the message. --- ui/app/AppLayouts/Chat/views/ChatColumnView.qml | 7 +++++++ .../Chat/views/ChatHeaderContentView.qml | 17 ++++++++++------- ui/app/AppLayouts/Chat/views/ChatView.qml | 6 ++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index 39982c55ef0..c04ba6911eb 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -58,9 +58,11 @@ Item { property bool amISectionAdmin: false property bool sendViaPersonalChatEnabled property bool paymentRequestFeatureEnabled + property bool selectingMembers signal openStickerPackPopup(string stickerPackId) signal tokenPaymentRequested(string recipientAddress, string symbol, string rawAmount, int chainId) + signal groupUpdated() // This function is called once `1:1` or `group` chat is created. function checkForCreateChatOptions(chatId) { @@ -374,6 +376,11 @@ Item { return } + // If the member selector is open, we update the group members and call for the menu to be closed + if (selectingMembers) { + d.activeUsersStore.updateGroupMembers() + root.groupUpdated() + } if (root.rootStore.sendMessage(d.activeChatContentModule.getMyChatId(), event, chatInput.getTextWithPublicKeys(), diff --git a/ui/app/AppLayouts/Chat/views/ChatHeaderContentView.qml b/ui/app/AppLayouts/Chat/views/ChatHeaderContentView.qml index 624225f4432..ccfc2420523 100644 --- a/ui/app/AppLayouts/Chat/views/ChatHeaderContentView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatHeaderContentView.qml @@ -28,6 +28,7 @@ Item { property var chatContentModule: root.rootStore.currentChatContentModule() || null property var emojiPopup property int padding: Theme.halfPadding + readonly property bool selectingMembers: root.state == d.stateMembersSelectorContent signal searchButtonClicked() signal displayEditChannelPopup(string chatId, @@ -44,13 +45,15 @@ Item { root.state = d.stateMembersSelectorContent } + function groupUpdated() { + root.state = d.stateInfoButtonContent + } + QtObject { id: d readonly property string stateInfoButtonContent: "" readonly property string stateMembersSelectorContent: "selectingMembers" - - readonly property bool selectingMembers: root.state == stateMembersSelectorContent } MessageStore { @@ -65,9 +68,9 @@ Item { anchors.top: parent.top anchors.bottom: parent.bottom anchors.left: parent.left - anchors.right: d.selectingMembers ? parent.right : actionButtons.left + anchors.right: root.selectingMembers ? parent.right : actionButtons.left - sourceComponent: d.selectingMembers ? membersSelector : statusChatInfoButton + sourceComponent: root.selectingMembers ? membersSelector : statusChatInfoButton } RowLayout { @@ -78,7 +81,7 @@ Item { anchors.right: parent.right spacing: 8 - visible: !d.selectingMembers + visible: !root.selectingMembers StatusFlatRoundButton { id: searchButton @@ -351,8 +354,8 @@ Item { } contactsModel: root.mutualContactsModel - onConfirmed: root.state = d.stateInfoButtonContent - onRejected: root.state = d.stateInfoButtonContent + onConfirmed: root.groupUpdated() + onRejected: root.groupUpdated() } } } diff --git a/ui/app/AppLayouts/Chat/views/ChatView.qml b/ui/app/AppLayouts/Chat/views/ChatView.qml index 0a0b46ffe92..b312784e39c 100644 --- a/ui/app/AppLayouts/Chat/views/ChatView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatView.qml @@ -291,6 +291,12 @@ StatusSectionLayout { amISectionAdmin: root.amISectionAdmin sendViaPersonalChatEnabled: root.sendViaPersonalChatEnabled paymentRequestFeatureEnabled: root.paymentRequestFeatureEnabled + selectingMembers: headerContentLoader.item && !!headerContentLoader.item.selectingMembers + onGroupUpdated: { + if (headerContentLoader.item && headerContentLoader.item instanceof ChatHeaderContentView) { + headerContentLoader.item.groupUpdated() + } + } onOpenStickerPackPopup: { Global.openPopup(statusStickerPackClickPopup, {packId: stickerPackId, store: root.stickersPopup.store} ) }