From ed7f7671550fe625cc6198535fe3dbd3089a6ea5 Mon Sep 17 00:00:00 2001 From: Boris Melnik Date: Mon, 7 Feb 2022 15:00:24 +0300 Subject: [PATCH] fix(groups): Add isMember method to chat content module Closes: #4615 --- .../main/chat_section/chat_content/users/view.nim | 3 +++ ui/app/AppLayouts/Chat/panels/ContactListPanel.qml | 10 ++++++++-- ui/app/AppLayouts/Chat/popups/GroupChatPopup.qml | 4 ++++ ui/app/AppLayouts/Chat/popups/GroupInfoPopup.qml | 7 ++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/app/modules/main/chat_section/chat_content/users/view.nim b/src/app/modules/main/chat_section/chat_content/users/view.nim index b575392ef0..8a6fb402ad 100644 --- a/src/app/modules/main/chat_section/chat_content/users/view.nim +++ b/src/app/modules/main/chat_section/chat_content/users/view.nim @@ -35,3 +35,6 @@ QtObject: QtProperty[QVariant] model: read = getModel notify = modelChanged + + proc isContactWithIdAdded*(self: View, id: string): bool {.slot.} = + return self.model.isContactWithIdAdded(id) diff --git a/ui/app/AppLayouts/Chat/panels/ContactListPanel.qml b/ui/app/AppLayouts/Chat/panels/ContactListPanel.qml index 5aa5d20300..406c9bea2b 100644 --- a/ui/app/AppLayouts/Chat/panels/ContactListPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/ContactListPanel.qml @@ -9,11 +9,16 @@ import utils 1.0 ScrollView { id: contactListPanel + property var chatContentModule property alias model: groupMembers.model property string searchString property bool selectMode: true property var onItemChecked + property var isMember: function (pubkey) { + return false + } + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ScrollBar.vertical.policy: groupMembers.contentHeight > groupMembers.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff @@ -31,14 +36,15 @@ ScrollView { image.isIdenticon: !!model.identicon visible: { if (selectMode) { - return !searchString || model.name.toLowerCase().includes(searchString) + return (!searchString || model.name.toLowerCase().includes(searchString)) + && !isMember(model.pubKey) } return checkbox.checked } components: [ StatusCheckBox { id: checkbox - visible: contactListPanel.selectMode && !model.isUser + visible: contactListPanel.selectMode && !isMember(model.pubKey) checked: contactDelegate.isChecked onClicked: { contactDelegate.isChecked = !contactDelegate.isChecked diff --git a/ui/app/AppLayouts/Chat/popups/GroupChatPopup.qml b/ui/app/AppLayouts/Chat/popups/GroupChatPopup.qml index 148b986813..8176e7d691 100644 --- a/ui/app/AppLayouts/Chat/popups/GroupChatPopup.qml +++ b/ui/app/AppLayouts/Chat/popups/GroupChatPopup.qml @@ -19,6 +19,7 @@ ModalPopup { id: popup property var chatSectionModule + property var chatContentModule property var store property var pubKeys: [] property bool selectChatMembers: true @@ -27,6 +28,8 @@ ModalPopup { property string channelNameValidationError: "" onOpened: { + popup.chatContentModule = popup.store.currentChatContentModule() + groupName.text = ""; searchBox.text = ""; selectChatMembers = true; @@ -129,6 +132,7 @@ ModalPopup { ContactListPanel { id: contactList anchors.fill: parent + chatContentModule: popup.chatContentModule model: chatSectionModule.listOfMyContacts searchString: searchBox.text.toLowerCase() selectMode: selectChatMembers && memberCount < maxMembers diff --git a/ui/app/AppLayouts/Chat/popups/GroupInfoPopup.qml b/ui/app/AppLayouts/Chat/popups/GroupInfoPopup.qml index 951c3ed706..a3053916aa 100644 --- a/ui/app/AppLayouts/Chat/popups/GroupInfoPopup.qml +++ b/ui/app/AppLayouts/Chat/popups/GroupInfoPopup.qml @@ -130,7 +130,7 @@ StatusModal { } NoFriendsRectangle { - visible: popup.store.addToGroupContacts.count === 0 && memberCount > 0 + visible: chatSectionModule.listOfMyContacts.rowCount() === 0 || chatSectionModule.listOfMyContacts.rowCount() <= memberCount - 1 //% "All your contacts are already in the group" text: qsTrId("group-chat-all-contacts-invited") textColor: Style.current.textColor @@ -142,10 +142,15 @@ StatusModal { ContactListPanel { id: contactList + chatContentModule: popup.chatContentModule visible: popup.chatContentModule.usersModule.model.rowCount() > 0 Layout.fillHeight: true Layout.fillWidth: true model: chatSectionModule.listOfMyContacts + isMember: function (pubKey) { + return chatContentModule.usersModule.isContactWithIdAdded(pubKey) + } + selectMode: memberCount < maxMembers searchString: searchBox.text.toLowerCase() onItemChecked: function(pubKey, itemChecked){