status-desktop/ui/app/AppLayouts/Chat/popups/GroupInfoPopup.qml

291 lines
9.5 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import StatusQ.Controls 0.1
import StatusQ.Components 0.1
import StatusQ.Popups 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import utils 1.0
import shared.views 1.0
import shared.panels 1.0
import shared.status 1.0
import "../panels"
2020-06-11 17:50:36 +00:00
StatusModal {
2020-06-11 17:50:36 +00:00
id: popup
fix: kick and re-invite user to group chat Fixes: #2601. Kicking a user and re-inviting them now correctly redisplays the join/decline options. Other combinations of User B leaving or declining an invitation are not handled. Please see the notes below for clarification. Additionally, the group invite popup (that shows the list of members belonging to the group) correctly shows when a user is kicked or when a user leaves the group in real time. Previously, the popup needed to be reopened to display this. fix: decline invitation crash Declining a group invitation was crashing the app. This has been fixed. ### NOTES 1. In the case where User A invites User B to a group, but User B declines (or User B joins, then leaves), then from a status-go standpoint, User B is still part of the group, but the chat is marked as `active: false` for User B. This creates a situation where User B cannot re-join the group once s/he has declined the invitation. @cammellos mentioned there possibly will need to be a refactor of https://github.com/status-im/status-go/blob/cab6281dc520c24912de5b5226b42a2f8415aa40/protocol/messenger.go#L1710 (which, by retaining User B as a member, effectively prevents the re-invitation) once “swipe to delete” is implemented on mobile. There is an activity center notification received for User B that is meant to allow re-joining of the group when the notification is accepted. The activity center notification received from status-go looks like the following: ```json "activityCenterNotifications": [ { "id": "0x0e342d33", "chatId": "e342d33f-dd05-4d7b-b14e-b5335e1a3ee9-0x043bf46aa874c377a34946eab67a32cf36c15907b328216dfce375d169fed7d81c21cada3229db1fd37c762d2c02702111a646657feca6621e2e948febcf378fb4", "name": "test-22", "type": 2, "lastMessage": null, "message": null, "timestamp": 1623305612000, "read": false, "dismissed": false, "accepted": false } ] ```
2021-06-10 07:29:05 +00:00
enum ChannelType {
ActiveChannel,
ContextChannel
}
property var chatSectionModule
property var store
property var messageStore
property bool addMembers: false
property int currMemberCount: chatContentModule.usersModule.model.count
property int memberCount: 1
fix: kick and re-invite user to group chat Fixes: #2601. Kicking a user and re-inviting them now correctly redisplays the join/decline options. Other combinations of User B leaving or declining an invitation are not handled. Please see the notes below for clarification. Additionally, the group invite popup (that shows the list of members belonging to the group) correctly shows when a user is kicked or when a user leaves the group in real time. Previously, the popup needed to be reopened to display this. fix: decline invitation crash Declining a group invitation was crashing the app. This has been fixed. ### NOTES 1. In the case where User A invites User B to a group, but User B declines (or User B joins, then leaves), then from a status-go standpoint, User B is still part of the group, but the chat is marked as `active: false` for User B. This creates a situation where User B cannot re-join the group once s/he has declined the invitation. @cammellos mentioned there possibly will need to be a refactor of https://github.com/status-im/status-go/blob/cab6281dc520c24912de5b5226b42a2f8415aa40/protocol/messenger.go#L1710 (which, by retaining User B as a member, effectively prevents the re-invitation) once “swipe to delete” is implemented on mobile. There is an activity center notification received for User B that is meant to allow re-joining of the group when the notification is accepted. The activity center notification received from status-go looks like the following: ```json "activityCenterNotifications": [ { "id": "0x0e342d33", "chatId": "e342d33f-dd05-4d7b-b14e-b5335e1a3ee9-0x043bf46aa874c377a34946eab67a32cf36c15907b328216dfce375d169fed7d81c21cada3229db1fd37c762d2c02702111a646657feca6621e2e948febcf378fb4", "name": "test-22", "type": 2, "lastMessage": null, "message": null, "timestamp": 1623305612000, "read": false, "dismissed": false, "accepted": false } ] ```
2021-06-10 07:29:05 +00:00
property int channelType: GroupInfoPopup.ChannelType.ActiveChannel
property var chatDetails
property bool isAdmin: popup.chatSectionModule.activeItem.amIChatAdmin
property var chatContentModule
readonly property int maxMembers: 20
function resetSelectedMembers() {
contactList.selectedPubKeys = []
memberCount = popup.chatContentModule.usersModule.model.count
}
2020-12-11 20:38:10 +00:00
function doAddMembers() {
if (popup.chatDetails.id && contactList.selectedPubKeys.length > 0) {
popup.chatSectionModule.addGroupMembers(popup.chatDetails.id, JSON.stringify(contactList.selectedPubKeys));
}
popup.close();
}
2020-12-11 20:38:10 +00:00
height: 504
anchors.centerIn: parent
header.title: addMembers ? qsTr("Add members") : (popup.chatDetails ? popup.chatDetails.name : "")
header.subTitle: {
if (addMembers) {
return qsTr("%1/%2 members").arg(memberCount).arg(maxMembers)
} else {
if (currMemberCount > 1) {
return qsTr("%1 members").arg(currMemberCount);
}
return qsTr("1 member");
}
}
header.editable: !addMembers && popup.isAdmin
header.icon.isLetterIdenticon: true
header.icon.name: popup.chatDetails ? popup.chatDetails.name : ""
header.icon.background.color: popup.chatDetails ? popup.chatDetails.color : "transparent"
onEditButtonClicked: renameGroupPopup.open()
onClosed: {
chatSectionModule.clearMyContacts()
popup.destroy();
}
onOpened: {
chatSectionModule.populateMyContacts(popup.chatContentModule.usersModule.getMembersPublicKeys())
addMembers = false;
btnSelectMembers.enabled = false;
resetSelectedMembers();
}
ColumnLayout {
id: addMembersItem
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 2 * Style.current.padding
height: parent.height
visible: addMembers
spacing: Style.current.padding
2020-06-15 12:51:04 +00:00
StatusInput {
id: searchBox
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
maximumHeight: 36
placeholderText: qsTr("Search")
input.placeholderFont.pixelSize: 15
input.icon.name: "search"
input.icon.width: 17
input.icon.height: 17
}
2020-12-11 20:38:10 +00:00
NoFriendsRectangle {
Layout.preferredHeight: childrenRect.height
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Layout.bottomMargin: childrenRect.height
visible: popup.store.contactsStore.myContactsModel.count === 0
}
NoFriendsRectangle {
Layout.preferredHeight: childrenRect.height
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Layout.bottomMargin: childrenRect.height
visible: chatSectionModule.listOfMyContacts.count === 0
text: qsTr("All your contacts are already in the group")
textColor: Style.current.textColor
}
ContactListPanel {
2020-12-11 20:38:10 +00:00
id: contactList
Layout.fillHeight: true
Layout.fillWidth: true
visible: popup.addMembers && chatSectionModule.listOfMyContacts.count > 0
model: chatSectionModule.listOfMyContacts
2020-12-11 20:38:10 +00:00
selectMode: memberCount < maxMembers
searchString: searchBox.text.toLowerCase()
onSelectedPubKeysChanged: {
memberCount = popup.chatContentModule.usersModule.model.count + selectedPubKeys.length;
btnSelectMembers.enabled = selectedPubKeys.length > 0
}
}
}
2020-06-11 17:50:36 +00:00
ColumnLayout {
id: groupInfoItem
2020-06-11 17:50:36 +00:00
anchors.top: parent.top
anchors.topMargin: Style.current.padding
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 2*Style.current.padding
height: parent.height - 2*Style.current.padding
visible: !addMembers
spacing: Style.current.padding
2020-06-11 17:50:36 +00:00
2021-05-25 19:38:18 +00:00
StatusSettingsLineButton {
property int pinnedCount: popup.chatContentModule.pinnedMessagesModel.count
2021-05-25 19:38:18 +00:00
id: pinnedMessagesBtn
visible: pinnedCount > 0
text: qsTr("Pinned messages")
2021-05-25 19:38:18 +00:00
currentValue: pinnedCount
onClicked: {
popup.store.messageStore.messageModule = popup.chatContentModule.messagesModule
popup.store.messageStore.chatSectionModule = popup.chatSectionModule
Global.openPopup(Global.pinnedMessagesPopup, {
store: popup.store,
messageStore: popup.store.messageStore,
pinnedMessagesModel: popup.chatContentModule.pinnedMessagesModel,
messageToPin: ""
})
}
iconSource: Style.svg("pin")
anchors.left: undefined
anchors.right: undefined
width: parent.width
2021-05-25 19:38:18 +00:00
}
Separator {
id: separator2
visible: pinnedMessagesBtn.visible
}
fix: kick and re-invite user to group chat Fixes: #2601. Kicking a user and re-inviting them now correctly redisplays the join/decline options. Other combinations of User B leaving or declining an invitation are not handled. Please see the notes below for clarification. Additionally, the group invite popup (that shows the list of members belonging to the group) correctly shows when a user is kicked or when a user leaves the group in real time. Previously, the popup needed to be reopened to display this. fix: decline invitation crash Declining a group invitation was crashing the app. This has been fixed. ### NOTES 1. In the case where User A invites User B to a group, but User B declines (or User B joins, then leaves), then from a status-go standpoint, User B is still part of the group, but the chat is marked as `active: false` for User B. This creates a situation where User B cannot re-join the group once s/he has declined the invitation. @cammellos mentioned there possibly will need to be a refactor of https://github.com/status-im/status-go/blob/cab6281dc520c24912de5b5226b42a2f8415aa40/protocol/messenger.go#L1710 (which, by retaining User B as a member, effectively prevents the re-invitation) once “swipe to delete” is implemented on mobile. There is an activity center notification received for User B that is meant to allow re-joining of the group when the notification is accepted. The activity center notification received from status-go looks like the following: ```json "activityCenterNotifications": [ { "id": "0x0e342d33", "chatId": "e342d33f-dd05-4d7b-b14e-b5335e1a3ee9-0x043bf46aa874c377a34946eab67a32cf36c15907b328216dfce375d169fed7d81c21cada3229db1fd37c762d2c02702111a646657feca6621e2e948febcf378fb4", "name": "test-22", "type": 2, "lastMessage": null, "message": null, "timestamp": 1623305612000, "read": false, "dismissed": false, "accepted": false } ] ```
2021-06-10 07:29:05 +00:00
StatusListView {
2020-06-11 17:50:36 +00:00
id: memberList
Layout.fillWidth: true
Layout.fillHeight: true
model: popup.chatContentModule.usersModule.model
delegate: StatusListItem {
id: contactRow
title: model.displayName
statusListItemTitle.font.pixelSize: 17
statusListItemTitleAside.font.pixelSize: 17
label: model.isAdmin ? qsTr("Admin"): ""
image.source: model.icon
ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.pubKey)
icon: StatusIconSettings {
color: Theme.palette.userCustomizationColors[Utils.colorIdForPubkey(model.pubKey)]
charactersLen: 2
isLetterIdenticon: model.icon === ""
height: isLetterIdenticon ? 40 : 20
width: isLetterIdenticon ? 40 : 20
}
components: [
StatusFlatRoundButton {
id: moreActionsBtn
type: StatusFlatRoundButton.Type.Tertiary
color: "transparent"
icon.name: "more"
icon.color: Theme.palette.baseColor1
visible: !model.isAdmin && popup.isAdmin
onClicked: {
contextMenu.popup(-contextMenu.width / 2 + moreActionsBtn.width / 2, moreActionsBtn.height + 10)
}
StatusPopupMenu {
id: contextMenu
StatusMenuItem {
icon.name: "admin"
icon.width: 16
icon.height: 16
text: qsTr("Make Admin")
onTriggered: popup.chatSectionModule.makeAdmin("", popup.chatDetails.id, model.pubKey)
}
StatusMenuItem {
icon.name: "remove-contact"
icon.width: 16
icon.height: 16
type: StatusMenuItem.Type.Danger
text: qsTr("Remove From Group")
onTriggered: popup.chatSectionModule.removeMemberFromGroupChat("", popup.chatDetails.id, model.pubKey)
}
}
2020-06-11 17:50:36 +00:00
}
]
onTitleClicked: {
Global.openProfilePopup(model.pubKey, popup)
2020-06-11 17:50:36 +00:00
}
}
}
}
leftButtons: [
StatusBackButton {
visible: popup.addMembers
onClicked: {
popup.addMembers = false;
popup.resetSelectedMembers();
}
}
]
rightButtons: [
StatusButton {
visible: !popup.addMembers && popup.isAdmin
text: qsTr("Add members")
onClicked: {
popup.addMembers = true;
}
},
StatusButton {
id: btnSelectMembers
visible: popup.addMembers
enabled: popup.memberCount >= popup.currMemberCount
text: qsTr("Add selected")
onClicked: popup.doAddMembers()
}
]
RenameGroupPopup {
id: renameGroupPopup
activeChannelName: popup.chatDetails ? popup.chatDetails.name : ""
onDoRename: {
popup.chatSectionModule.renameGroupChat(popup.chatSectionModule.activeItem.id, groupName)
popup.header.title = groupName
close()
}
}
2020-06-11 17:50:36 +00:00
}