2021-01-21 14:39:27 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import "./"
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
|
|
|
|
|
|
|
PopupMenu {
|
|
|
|
property int channelIndex
|
2021-02-17 21:06:16 +00:00
|
|
|
property var contextChannel: ({})
|
2021-01-21 14:39:27 +00:00
|
|
|
|
|
|
|
id: channelContextMenu
|
|
|
|
width: 175
|
|
|
|
subMenuIcons: [
|
|
|
|
/* { */
|
|
|
|
/* source: Qt.resolvedUrl("../../../img/bell.svg"), */
|
|
|
|
/* width: 16, */
|
|
|
|
/* height: 16 */
|
|
|
|
/* }, */
|
|
|
|
{
|
|
|
|
source: Qt.resolvedUrl("../../../img/fetch.svg"),
|
|
|
|
width: 16,
|
|
|
|
height: 16
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2021-02-12 18:38:25 +00:00
|
|
|
function openMenu(channel, index, x, y) {
|
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
|
|
|
channelContextMenu.contextChannel = channel
|
2021-01-21 14:39:27 +00:00
|
|
|
if (index !== undefined) {
|
|
|
|
channelContextMenu.channelIndex = index
|
|
|
|
}
|
2021-02-12 18:38:25 +00:00
|
|
|
channelContextMenu.popup(x, y)
|
2021-01-21 14:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Action {
|
2021-02-12 18:38:25 +00:00
|
|
|
id: viewProfileButton
|
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
|
|
|
enabled: channelContextMenu.contextChannel.chatType !== Constants.chatTypePublic
|
2021-01-21 14:39:27 +00:00
|
|
|
text: {
|
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 (channelContextMenu.contextChannel.chatType === Constants.chatTypeOneToOne) {
|
2021-01-21 14:39:27 +00:00
|
|
|
//% "View Profile"
|
|
|
|
return qsTrId("view-profile")
|
|
|
|
}
|
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 (channelContextMenu.contextChannel.chatType === Constants.chatTypePrivateGroupChat) {
|
2021-01-21 14:39:27 +00:00
|
|
|
//% "View Group"
|
|
|
|
return qsTrId("view-group")
|
|
|
|
}
|
|
|
|
//% "Share Chat"
|
|
|
|
return qsTrId("share-chat")
|
|
|
|
}
|
|
|
|
icon.source: "../../../img/group.svg"
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
|
|
|
onTriggered: {
|
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 (channelContextMenu.contextChannel.chatType === Constants.chatTypeOneToOne) {
|
|
|
|
const userProfileImage = appMain.getProfileImage(channelContextMenu.contextChannel.id)
|
|
|
|
return openProfilePopup(
|
|
|
|
channelContextMenu.contextChannel.name,
|
|
|
|
channelContextMenu.contextChannel.id,
|
|
|
|
userProfileImage || channelContextMenu.contextChannel.identicon
|
|
|
|
)
|
2021-01-21 14:39:27 +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
|
|
|
if (channelContextMenu.contextChannel.chatType === Constants.chatTypePrivateGroupChat) {
|
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
|
|
|
return openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ContextChannel})
|
2021-01-21 14:39:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-12 18:38:25 +00:00
|
|
|
Separator {
|
|
|
|
visible: viewProfileButton.enabled
|
|
|
|
}
|
2021-01-21 14:39:27 +00:00
|
|
|
|
|
|
|
Action {
|
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: channelContextMenu.contextChannel.muted ?
|
2021-01-21 14:39:27 +00:00
|
|
|
//% "Unmute chat"
|
|
|
|
qsTrId("unmute-chat") :
|
|
|
|
//% "Mute chat"
|
|
|
|
qsTrId("mute-chat")
|
|
|
|
icon.source: "../../../img/bell.svg"
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
|
|
|
onTriggered: {
|
2021-06-17 22:09:00 +00:00
|
|
|
if (chatsModel.channelView.channelIsMuted(channelContextMenu.channelIndex)) {
|
|
|
|
chatsModel.channelView.unmuteChannel(channelContextMenu.channelIndex)
|
2021-01-21 14:39:27 +00:00
|
|
|
return
|
|
|
|
}
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.muteChannel(channelContextMenu.channelIndex)
|
2021-01-21 14:39:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Action {
|
|
|
|
//% "Mark as Read"
|
|
|
|
text: qsTrId("mark-as-read")
|
|
|
|
icon.source: "../../../img/check-circle.svg"
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
|
|
|
onTriggered: {
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.markAllChannelMessagesReadByIndex(channelContextMenu.channelIndex)
|
2021-01-21 14:39:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-24 14:19:53 +00:00
|
|
|
// FetchMoreMessages {} // TODO: disabling it temporarily because wakuext_syncChatFromSyncedFrom does not support specifying a date range
|
2021-01-21 14:39:27 +00:00
|
|
|
Action {
|
|
|
|
//% "Clear History"
|
|
|
|
text: qsTrId("clear-history")
|
|
|
|
icon.source: "../../../img/close.svg"
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
2021-06-17 22:09:00 +00:00
|
|
|
onTriggered: chatsModel.channelView.clearChatHistoryByIndex(channelContextMenu.channelIndex)
|
2021-01-21 14:39:27 +00:00
|
|
|
}
|
2021-05-28 02:55:50 +00:00
|
|
|
Action {
|
|
|
|
enabled: chatsModel.communities.activeCommunity.active && chatsModel.communities.activeCommunity.admin
|
|
|
|
text: qsTr("Edit Channel")
|
|
|
|
icon.source: "../../../img/edit.svg"
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
2021-06-17 22:09:00 +00:00
|
|
|
onTriggered: openPopup(editChannelPopup, {communityId: chatsModel.communities.activeCommunity.id, channel: chatsModel.channelView.activeChannel})
|
2021-05-28 02:55:50 +00:00
|
|
|
}
|
2021-01-21 14:39:27 +00:00
|
|
|
|
2021-04-20 15:54:33 +00:00
|
|
|
Separator {
|
|
|
|
visible: deleteAction.enabled
|
|
|
|
}
|
2021-01-21 14:39:27 +00:00
|
|
|
|
|
|
|
Action {
|
2021-04-20 15:54:33 +00:00
|
|
|
id: deleteAction
|
2021-01-21 14:39:27 +00:00
|
|
|
text: {
|
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 (channelContextMenu.contextChannel.chatType === Constants.chatTypeOneToOne) {
|
2021-01-21 14:39:27 +00:00
|
|
|
//% "Delete chat"
|
|
|
|
return qsTrId("delete-chat")
|
|
|
|
}
|
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 (channelContextMenu.contextChannel.chatType === Constants.chatTypePrivateGroupChat) {
|
2021-01-21 14:39:27 +00:00
|
|
|
//% "Leave group"
|
|
|
|
return qsTrId("leave-group")
|
|
|
|
}
|
|
|
|
//% "Leave chat"
|
|
|
|
return qsTrId("leave-chat")
|
|
|
|
}
|
|
|
|
icon.source: {
|
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 (channelContextMenu.contextChannel.chatType === Constants.chatTypeOneToOne) {
|
2021-01-21 14:39:27 +00:00
|
|
|
return "../../../img/delete.svg"
|
|
|
|
}
|
|
|
|
return "../../../img/leave_chat.svg"
|
|
|
|
}
|
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
2021-04-27 18:02:45 +00:00
|
|
|
icon.color: Style.current.red
|
2021-05-03 20:01:42 +00:00
|
|
|
onTriggered: openPopup(deleteChatConfirmationDialogComponent)
|
2021-04-20 15:54:33 +00:00
|
|
|
enabled: !chatsModel.communities.activeCommunity.active
|
2021-01-21 14:39:27 +00:00
|
|
|
}
|
2021-05-03 20:01:42 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: deleteChatConfirmationDialogComponent
|
|
|
|
ConfirmationDialog {
|
|
|
|
btnType: "warn"
|
2021-05-04 14:53:56 +00:00
|
|
|
confirmationText: qsTr("Are you sure you want to leave this chat?")
|
2021-05-03 20:01:42 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
onConfirmButtonClicked: {
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.leaveChatByIndex(channelContextMenu.channelIndex)
|
2021-05-03 20:01:42 +00:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-21 14:39:27 +00:00
|
|
|
}
|
|
|
|
|