fix(groups): Update group info user list

Closes: #4533
This commit is contained in:
Boris Melnik 2022-01-26 01:10:35 +03:00 committed by Sale Djenic
parent 900c6528ac
commit 15793b2a35
1 changed files with 19 additions and 18 deletions

View File

@ -35,13 +35,14 @@ StatusModal {
property bool isAdmin: false property bool isAdmin: false
property Component pinnedMessagesPopupComponent property Component pinnedMessagesPopupComponent
property var chatContentModule
function resetSelectedMembers(){ function resetSelectedMembers(){
pubKeys = [] pubKeys = []
memberCount = channel ? channel.members.rowCount() : 0 memberCount = popup.chatContentModule.usersModule.model.rowCount()
currMemberCount = memberCount currMemberCount = memberCount
popup.store.addToGroupContacts.clear() popup.store.addToGroupContacts.clear()
popup.store.reCalculateAddToGroupContacts(channel)
} }
function doAddMembers(){ function doAddMembers(){
@ -77,10 +78,15 @@ StatusModal {
onEditButtonClicked: renameGroupPopup.open() onEditButtonClicked: renameGroupPopup.open()
onClosed: { onClosed: {
chatSectionModule.clearMyContacts()
popup.destroy(); popup.destroy();
} }
onOpened: { onOpened: {
popup.chatContentModule = popup.store.currentChatContentModule()
chatSectionModule.populateMyContacts()
addMembers = false; addMembers = false;
if (popup.channel) { if (popup.channel) {
popup.isAdmin = popup.chatSectionModule.activeItem.amIChatAdmin popup.isAdmin = popup.chatSectionModule.activeItem.amIChatAdmin
@ -136,10 +142,10 @@ StatusModal {
ContactListPanel { ContactListPanel {
id: contactList id: contactList
visible: popup.store.addToGroupContacts.count > 0 visible: popup.chatContentModule.usersModule.model.rowCount() > 0
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
model: popup.store.addToGroupContacts model: chatSectionModule.listOfMyContacts
selectMode: memberCount < maxMembers selectMode: memberCount < maxMembers
searchString: searchBox.text.toLowerCase() searchString: searchBox.text.toLowerCase()
onItemChecked: function(pubKey, itemChecked){ onItemChecked: function(pubKey, itemChecked){
@ -153,7 +159,7 @@ StatusModal {
pubKeys.splice(idx, 1); pubKeys.splice(idx, 1);
} }
} }
memberCount = popup.channel.members.rowCount() + pubKeys.length; memberCount = popup.chatContentModule.usersModule.model.rowCount() + pubKeys.length;
btnSelectMembers.enabled = pubKeys.length > 0 btnSelectMembers.enabled = pubKeys.length > 0
} }
} }
@ -163,7 +169,7 @@ StatusModal {
id: groupInfoItem id: groupInfoItem
width: parent.width - 2*Style.current.padding width: parent.width - 2*Style.current.padding
height: parent.height - 2*Style.current.padding height: parent.height
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Style.current.padding anchors.topMargin: Style.current.padding
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -208,25 +214,20 @@ StatusModal {
ListView { ListView {
id: memberList id: memberList
spacing: Style.current.padding
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
clip: true model: popup.chatContentModule.usersModule.model
model: popup.channel? popup.channel.members : []
delegate: StatusListItem { delegate: StatusListItem {
id: contactRow id: contactRow
property string nickname: Utils.getContactDetailsAsJson(model.publicKey).localNickname title: model.name
title: !model.userName.endsWith(".eth") && !!contactRow.nickname ?
contactRow.nickname : Utils.removeStatusEns(model.userName)
//% "(You)"
titleAsideText: model.publicKey === userProfile.pubKey ? qsTrId("-you-") : ""
//% "Admin" //% "Admin"
statusListItemTitle.font.pixelSize: 17 statusListItemTitle.font.pixelSize: 17
statusListItemTitleAside.font.pixelSize: 17 statusListItemTitleAside.font.pixelSize: 17
label: model.isAdmin ? qsTrId("group-chat-admin"): "" label: model.isAdmin ? qsTrId("group-chat-admin"): ""
image.source: Global.getProfileImage(model.publicKey) || model.identicon image.source: model.icon
image.isIdenticon: model.identicon image.isIdenticon: model.isIdenticon
components: [ components: [
StatusFlatRoundButton { StatusFlatRoundButton {
id: moreActionsBtn id: moreActionsBtn
@ -246,7 +247,7 @@ StatusModal {
icon.height: 16 icon.height: 16
//% "Make Admin" //% "Make Admin"
text: qsTrId("make-admin") text: qsTrId("make-admin")
onTriggered: popup.chatSectionModule.makeAdmin(popup.channel.id, model.publicKey) onTriggered: popup.chatSectionModule.makeAdmin(popup.channel.id, model.id)
} }
StatusMenuItem { StatusMenuItem {
icon.name: "remove-contact" icon.name: "remove-contact"
@ -255,7 +256,7 @@ StatusModal {
type: StatusMenuItem.Type.Danger type: StatusMenuItem.Type.Danger
//% "Remove From Group" //% "Remove From Group"
text: qsTrId("remove-from-group") text: qsTrId("remove-from-group")
onTriggered: popup.chatSectionModule.removeMemberFromGroupChat(popup.channel.id, model.publicKey) onTriggered: popup.chatSectionModule.removeMemberFromGroupChat(popup.channel.id, model.id)
} }
} }
} }