2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-11 17:50:36 +00:00
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
2020-09-22 14:45:09 +00:00
|
|
|
import "../../../../shared/status"
|
2020-06-11 17:50:36 +00:00
|
|
|
import "./"
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
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
|
|
|
|
}
|
2020-06-22 17:24:01 +00:00
|
|
|
property bool addMembers: false
|
|
|
|
property int currMemberCount: 1
|
|
|
|
property int memberCount: 1
|
|
|
|
readonly property int maxMembers: 10
|
|
|
|
property var pubKeys: []
|
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 QtObject channel: {
|
|
|
|
if (channelType === GroupInfoPopup.ChannelType.ActiveChannel) {
|
2021-06-17 22:09:00 +00:00
|
|
|
return chatsModel.channelView.activeChannel
|
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
|
|
|
} else if (channelType === GroupInfoPopup.ChannelType.ContextChannel) {
|
2021-06-17 22:09:00 +00:00
|
|
|
return chatsModel.channelView.contextChannel
|
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
|
|
|
}
|
|
|
|
}
|
2020-10-20 19:46:49 +00:00
|
|
|
property bool isAdmin: false
|
2021-05-25 19:38:18 +00:00
|
|
|
property Component pinnedMessagesPopupComponent
|
2020-06-22 17:24:01 +00:00
|
|
|
|
|
|
|
function resetSelectedMembers(){
|
|
|
|
pubKeys = [];
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
memberCount = channel.members.rowCount();
|
2020-06-22 17:24:01 +00:00
|
|
|
currMemberCount = memberCount;
|
2020-12-11 20:38:10 +00:00
|
|
|
contactList.membersData.clear();
|
|
|
|
|
2021-03-29 19:31:18 +00:00
|
|
|
const contacts = getContactListObject()
|
2020-12-11 20:38:10 +00:00
|
|
|
|
|
|
|
contacts.forEach(function (contact) {
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
if(popup.channel.contains(contact.pubKey) ||
|
2020-12-11 20:38:10 +00:00
|
|
|
!contact.isContact) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
contactList.membersData.append(contact)
|
|
|
|
})
|
2020-06-22 17:24:01 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 20:36:10 +00:00
|
|
|
onClosed: {
|
|
|
|
popup.destroy();
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
}
|
|
|
|
|
2020-06-22 17:24:01 +00:00
|
|
|
onOpened: {
|
|
|
|
addMembers = false;
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
popup.isAdmin = popup.channel.isAdmin(profileModel.profile.pubKey)
|
2020-06-22 17:24:01 +00:00
|
|
|
btnSelectMembers.enabled = false;
|
|
|
|
resetSelectedMembers();
|
|
|
|
}
|
|
|
|
|
|
|
|
function doAddMembers(){
|
|
|
|
if(pubKeys.length === 0) return;
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
chatsModel.groups.addMembers(popup.channel.id, JSON.stringify(pubKeys));
|
2020-06-22 17:24:01 +00:00
|
|
|
popup.close();
|
|
|
|
}
|
2020-06-11 17:50:36 +00:00
|
|
|
|
|
|
|
header: Item {
|
|
|
|
height: children[0].height
|
|
|
|
width: parent.width
|
|
|
|
|
2020-09-22 14:45:09 +00:00
|
|
|
|
|
|
|
StatusLetterIdenticon {
|
2020-06-11 17:50:36 +00:00
|
|
|
id: letterIdenticon
|
|
|
|
width: 36
|
|
|
|
height: 36
|
|
|
|
anchors.top: parent.top
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
color: popup.channel.color
|
2021-03-02 20:43:32 +00:00
|
|
|
chatId: popup.channel.id
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
chatName: popup.channel.name
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 18:21:02 +00:00
|
|
|
StyledTextEdit {
|
2020-06-11 17:50:36 +00:00
|
|
|
id: groupName
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Add members"
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
text: addMembers ? qsTrId("add-members") : popup.channel.name
|
2020-06-11 17:50:36 +00:00
|
|
|
anchors.top: parent.top
|
2020-10-20 19:19:10 +00:00
|
|
|
anchors.topMargin: 2
|
2020-06-11 17:50:36 +00:00
|
|
|
anchors.left: letterIdenticon.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2020-06-11 17:50:36 +00:00
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 14
|
|
|
|
readOnly: true
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-11 17:50:36 +00:00
|
|
|
text: {
|
2020-06-22 17:24:01 +00:00
|
|
|
let cnt = memberCount;
|
|
|
|
if(addMembers){
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "%1 / 10 members"
|
|
|
|
return qsTrId("%1-/-10-members").arg(cnt)
|
2020-06-22 17:24:01 +00:00
|
|
|
} else {
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "%1 members"
|
|
|
|
if(cnt > 1) return qsTrId("%1-members").arg(cnt);
|
|
|
|
//% "1 member"
|
|
|
|
return qsTrId("1-member");
|
2020-06-22 17:24:01 +00:00
|
|
|
}
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
|
|
|
width: 160
|
|
|
|
anchors.left: letterIdenticon.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2020-06-11 17:50:36 +00:00
|
|
|
anchors.top: groupName.bottom
|
|
|
|
anchors.topMargin: 2
|
|
|
|
font.pixelSize: 14
|
2021-05-25 19:38:18 +00:00
|
|
|
color: Style.current.secondaryText
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
2020-06-15 12:51:04 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: editGroupNameBtn
|
2020-10-20 19:46:49 +00:00
|
|
|
visible: !addMembers && popup.isAdmin
|
2020-06-15 12:51:04 +00:00
|
|
|
height: 24
|
|
|
|
width: 24
|
2020-10-20 19:19:10 +00:00
|
|
|
anchors.verticalCenter: groupName.verticalCenter
|
2021-05-25 19:38:18 +00:00
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
2020-06-15 12:51:04 +00:00
|
|
|
anchors.left: groupName.right
|
|
|
|
radius: 8
|
|
|
|
|
2020-06-25 13:23:17 +00:00
|
|
|
SVGImage {
|
2020-06-15 12:51:04 +00:00
|
|
|
id: editGroupImg
|
|
|
|
source: "../../../img/edit-group.svg"
|
2020-08-07 19:26:51 +00:00
|
|
|
height: 16
|
|
|
|
width: 16
|
2020-06-15 12:51:04 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: closeModalMouseArea
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onExited: {
|
2020-07-02 15:14:31 +00:00
|
|
|
editGroupNameBtn.color = Style.current.white
|
2020-06-15 12:51:04 +00:00
|
|
|
}
|
|
|
|
onEntered: {
|
2020-07-02 15:14:31 +00:00
|
|
|
editGroupNameBtn.color = Style.current.grey
|
2020-06-15 12:51:04 +00:00
|
|
|
}
|
|
|
|
onClicked: renameGroupPopup.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RenameGroupPopup {
|
|
|
|
id: renameGroupPopup
|
|
|
|
}
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
|
|
|
|
2020-06-22 17:24:01 +00:00
|
|
|
Item {
|
|
|
|
id: addMembersItem
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
|
|
|
visible: addMembers
|
|
|
|
iconWidth: 17
|
|
|
|
iconHeight: 17
|
|
|
|
customHeight: 44
|
|
|
|
fontPixelSize: 15
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
NoFriendsRectangle {
|
2021-07-13 07:56:18 +00:00
|
|
|
visible: contactList.membersData.count === 0 && memberCount === 0
|
|
|
|
anchors.top: searchBox.bottom
|
|
|
|
anchors.topMargin: Style.current.xlPadding
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
NoFriendsRectangle {
|
|
|
|
visible: contactList.membersData.count === 0 && memberCount > 0
|
|
|
|
width: 340
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "All your contacts are already in the group"
|
|
|
|
text: qsTrId("group-chat-all-contacts-invited")
|
2021-07-13 07:56:18 +00:00
|
|
|
textColor: Style.current.textColor
|
2020-08-10 02:14:21 +00:00
|
|
|
anchors.top: searchBox.bottom
|
|
|
|
anchors.topMargin: Style.current.xlPadding
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
ContactList {
|
|
|
|
id: contactList
|
|
|
|
visible: addMembers && contactList.membersData.count > 0
|
2020-06-22 17:24:01 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: 50
|
|
|
|
anchors.top: searchBox.bottom
|
2020-12-11 20:38:10 +00:00
|
|
|
selectMode: memberCount < maxMembers
|
|
|
|
searchString: searchBox.text.toLowerCase()
|
|
|
|
onItemChecked: function(pubKey, itemChecked){
|
|
|
|
var idx = pubKeys.indexOf(pubKey)
|
|
|
|
if(itemChecked){
|
|
|
|
if(idx === -1){
|
|
|
|
pubKeys.push(pubKey)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(idx > -1){
|
|
|
|
pubKeys.splice(idx, 1);
|
2020-06-22 17:24:01 +00:00
|
|
|
}
|
|
|
|
}
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
memberCount = popup.channel.members.rowCount() + pubKeys.length;
|
2020-12-11 20:38:10 +00:00
|
|
|
btnSelectMembers.enabled = pubKeys.length > 0
|
2020-06-22 17:24:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-11 17:50:36 +00:00
|
|
|
|
|
|
|
Item {
|
2020-06-22 17:24:01 +00:00
|
|
|
id: groupInfoItem
|
2020-06-11 17:50:36 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2021-01-18 20:53:02 +00:00
|
|
|
Separator {
|
|
|
|
id: separator
|
|
|
|
visible: !addMembers
|
2021-02-17 20:36:10 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
StatusSettingsLineButton {
|
2021-06-21 19:35:32 +00:00
|
|
|
property int pinnedCount: chatsModel.messageView.pinnedMessagesList.count
|
2021-05-25 19:38:18 +00:00
|
|
|
|
|
|
|
id: pinnedMessagesBtn
|
|
|
|
visible: pinnedCount > 0
|
|
|
|
height: visible ? implicitHeight : 0
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Pinned messages"
|
|
|
|
text: qsTrId("pinned-messages")
|
2021-05-25 19:38:18 +00:00
|
|
|
currentValue: pinnedCount
|
|
|
|
anchors.top: separator.bottom
|
|
|
|
anchors.topMargin: visible ? Style.current.halfPadding : 0
|
|
|
|
anchors.leftMargin: 0
|
|
|
|
anchors.rightMargin: 0
|
|
|
|
onClicked: openPopup(pinnedMessagesPopupComponent)
|
|
|
|
iconSource: "../../../img/pin.svg"
|
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
id: separator2
|
|
|
|
visible: pinnedMessagesBtn.visible
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
anchors.top: pinnedMessagesBtn.bottom
|
|
|
|
anchors.topMargin: visible ? Style.current.halfPadding : 0
|
|
|
|
}
|
|
|
|
|
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
|
|
|
Connections {
|
2021-06-17 22:09:00 +00:00
|
|
|
target: chatsModel.channelView
|
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
|
|
|
onActiveChannelChanged: {
|
|
|
|
if (popup.channelType === GroupInfoPopup.ChannelType.ActiveChannel) {
|
2021-06-17 22:09:00 +00:00
|
|
|
popup.channel = chatsModel.channelView.activeChannel
|
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
|
|
|
resetSelectedMembers()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onContextChannelChanged: {
|
|
|
|
if (popup.channelType === GroupInfoPopup.ChannelType.ContextChannel) {
|
2021-06-17 22:09:00 +00:00
|
|
|
popup.channel = chatsModel.channelView.contextChannel
|
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
|
|
|
resetSelectedMembers()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 17:50:36 +00:00
|
|
|
ListView {
|
|
|
|
id: memberList
|
2021-05-25 19:38:18 +00:00
|
|
|
anchors.top: separator2.bottom
|
2021-05-26 15:43:03 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2021-05-25 19:38:18 +00:00
|
|
|
anchors.topMargin: addMembers ? 30 : Style.current.padding
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.bottomMargin: Style.current.padding
|
2021-05-25 19:38:18 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
spacing: Style.current.padding
|
2020-06-11 17:50:36 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
model: popup.channel.members
|
2020-10-20 19:19:10 +00:00
|
|
|
delegate: Item {
|
2020-09-17 19:39:02 +00:00
|
|
|
id: contactRow
|
2020-10-20 19:19:10 +00:00
|
|
|
width: parent.width
|
|
|
|
height: identicon.height
|
|
|
|
|
2021-01-14 16:03:00 +00:00
|
|
|
property string nickname: appMain.getUserNickname(model.pubKey)
|
2020-09-17 19:39:02 +00:00
|
|
|
|
2020-10-20 19:19:10 +00:00
|
|
|
StatusImageIdenticon {
|
|
|
|
id: identicon
|
|
|
|
anchors.left: parent.left
|
2020-12-21 12:08:44 +00:00
|
|
|
source: appMain.getProfileImage(model.pubKey)|| model.identicon
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
2020-10-20 19:19:10 +00:00
|
|
|
|
|
|
|
StyledText {
|
|
|
|
text: !model.userName.endsWith(".eth") && !!contactRow.nickname ?
|
|
|
|
contactRow.nickname : Utils.removeStatusEns(model.userName)
|
|
|
|
anchors.left: identicon.right
|
2021-05-03 17:01:20 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-10-20 19:19:10 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-05-03 17:01:20 +00:00
|
|
|
font.pixelSize: 17
|
|
|
|
|
2021-01-18 20:53:02 +00:00
|
|
|
StyledText {
|
2021-01-19 15:02:47 +00:00
|
|
|
visible: model.pubKey === profileModel.profile.pubKey
|
2021-01-18 20:53:02 +00:00
|
|
|
anchors.left: parent.right
|
|
|
|
anchors.leftMargin: 5
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "(You)"
|
|
|
|
text: qsTrId("-you-")
|
2021-01-19 15:02:47 +00:00
|
|
|
color: Style.current.secondaryText
|
2021-01-18 20:53:02 +00:00
|
|
|
font.pixelSize: parent.font.pixelSize
|
|
|
|
}
|
2020-10-20 19:19:10 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2020-11-30 17:03:52 +00:00
|
|
|
onClicked: {
|
2020-12-21 12:08:44 +00:00
|
|
|
const userProfileImage = appMain.getProfileImage(model.pubKey)
|
2021-07-06 15:25:14 +00:00
|
|
|
openProfilePopup(model.userName, model.pubKey, userProfileImage || model.identicon, '', contactRow.nickname, popup)
|
2020-11-30 17:03:52 +00:00
|
|
|
}
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
2020-10-20 19:19:10 +00:00
|
|
|
}
|
2020-08-06 13:37:09 +00:00
|
|
|
|
2020-10-20 19:19:10 +00:00
|
|
|
StyledText {
|
|
|
|
id: adminLabel
|
|
|
|
visible: model.isAdmin
|
|
|
|
//% "Admin"
|
|
|
|
text: qsTrId("group-chat-admin")
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
font.pixelSize: 13
|
2021-01-19 15:02:47 +00:00
|
|
|
color: Style.current.secondaryText
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
2020-10-20 19:19:10 +00:00
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: moreActionsBtn
|
2020-10-20 19:46:49 +00:00
|
|
|
visible: !model.isAdmin && popup.isAdmin
|
2020-10-20 19:19:10 +00:00
|
|
|
text: "..."
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-01-18 20:53:02 +00:00
|
|
|
font.pixelSize: 20
|
|
|
|
font.bold: true
|
2021-01-19 15:02:47 +00:00
|
|
|
color: Style.current.secondaryText
|
2020-10-20 19:19:10 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
contextMenu.popup(-contextMenu.width / 2 + moreActionsBtn.width / 2, moreActionsBtn.height + 10)
|
|
|
|
}
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
PopupMenu {
|
|
|
|
id: contextMenu
|
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/make-admin.svg"
|
2021-04-27 17:26:13 +00:00
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
2020-10-20 19:19:10 +00:00
|
|
|
//% "Make Admin"
|
|
|
|
text: qsTrId("make-admin")
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
onTriggered: chatsModel.groups.makeAdmin(popup.channel.id, model.pubKey)
|
2020-06-12 14:01:46 +00:00
|
|
|
}
|
2020-10-20 19:19:10 +00:00
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/remove-from-group.svg"
|
2021-04-27 17:26:13 +00:00
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
2020-10-20 19:19:10 +00:00
|
|
|
icon.color: Style.current.red
|
|
|
|
//% "Remove From Group"
|
|
|
|
text: qsTrId("remove-from-group")
|
refactor(ChannelContextMenu): remove dependency on active channel
This commit does a bunch of things:
- First and foremost, it removes the active channel dependency.
This is needed to have it operate on the correct channel object,
without forcing us to change the active channel (e.g. right-clicking
on a channel item that's not active, will make it active eventually)
- To make that work, this commit changes the `ChannelContextMenu`
to receive a `ChatItemView`, so it can be used for things like determining
what menu options are shown, what members are in a group, whether
someone is admin of a group etc.
- This also required a new `QtProperty` called `contextChannel`.
The reason this is required, is because in some cases, like receiving
members count of groups, we need a complete `ChatItemView` object
as we don't have access to certain APIs otherwise.
- Unfortunately, we can't pass down `activeChannel` every where for that
because sometimes the context menu should not actually operate on
the active channel.
Fixes: #1755
2021-01-25 15:58:33 +00:00
|
|
|
onTriggered: chatsModel.groups.kickMember(popup.channel.id, model.pubKey)
|
2020-06-12 14:01:46 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-22 17:24:01 +00:00
|
|
|
|
|
|
|
footer: Item {
|
2020-10-20 19:46:49 +00:00
|
|
|
visible: popup.isAdmin
|
2020-06-22 17:24:01 +00:00
|
|
|
width: parent.width
|
|
|
|
height: children[0].height
|
2021-01-28 11:04:10 +00:00
|
|
|
StatusButton {
|
2020-06-22 17:24:01 +00:00
|
|
|
visible: !addMembers
|
|
|
|
anchors.right: parent.right
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Add members"
|
2021-01-28 11:04:10 +00:00
|
|
|
text: qsTrId("add-members")
|
2020-06-22 17:24:01 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
onClicked: {
|
|
|
|
addMembers = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 11:17:46 +00:00
|
|
|
StatusRoundButton {
|
2020-06-22 17:24:01 +00:00
|
|
|
id: btnBack
|
|
|
|
visible: addMembers
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
2021-01-28 11:17:46 +00:00
|
|
|
icon.name: "arrow-right"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 16
|
|
|
|
rotation: 180
|
|
|
|
onClicked : {
|
|
|
|
addMembers = false;
|
|
|
|
resetSelectedMembers();
|
2020-06-22 17:24:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 11:04:10 +00:00
|
|
|
StatusButton {
|
2020-06-22 17:24:01 +00:00
|
|
|
id: btnSelectMembers
|
|
|
|
visible: addMembers
|
2021-01-28 11:04:10 +00:00
|
|
|
enabled: memberCount >= currMemberCount
|
2020-06-22 17:24:01 +00:00
|
|
|
anchors.right: parent.right
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Add selected"
|
2021-01-28 11:04:10 +00:00
|
|
|
text: qsTrId("add-selected")
|
2020-06-22 17:24:01 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
onClicked: doAddMembers()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
content: addMembers ? addMembersItem : groupInfoItem
|
2020-06-11 17:50:36 +00:00
|
|
|
}
|