fix(groups): Add isMember method to chat content module

Closes: #4615
This commit is contained in:
Boris Melnik 2022-02-07 15:00:24 +03:00
parent 2689a08ebb
commit ed7f767155
No known key found for this signature in database
GPG Key ID: 4A9B2E42E3BD4727
4 changed files with 21 additions and 3 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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){