2021-07-06 09:42:51 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-15 10:59:01 +00:00
|
|
|
import Qt.labs.platform 1.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-07-06 09:42:51 +00:00
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.popups 1.0
|
2022-06-10 11:12:03 +00:00
|
|
|
import shared.controls.chat.menuItems 1.0
|
2021-10-25 09:57:09 +00:00
|
|
|
import "../popups"
|
2021-12-23 21:06:27 +00:00
|
|
|
import "../popups/community"
|
2021-10-25 09:57:09 +00:00
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusPopupMenu {
|
2021-10-21 22:39:53 +00:00
|
|
|
id: root
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
property string currentFleet: ""
|
|
|
|
property bool isCommunityChat: false
|
2022-01-05 15:50:03 +00:00
|
|
|
property bool amIChatAdmin: false
|
2021-12-09 12:53:40 +00:00
|
|
|
property string chatId: ""
|
|
|
|
property string chatName: ""
|
2021-12-21 09:26:13 +00:00
|
|
|
property string chatDescription: ""
|
2022-03-07 14:56:05 +00:00
|
|
|
property string chatEmoji: ""
|
2022-03-10 19:28:37 +00:00
|
|
|
property string chatColor: ""
|
2021-12-09 12:53:40 +00:00
|
|
|
property string chatIcon: ""
|
|
|
|
property int chatType: -1
|
|
|
|
property bool chatMuted: false
|
2022-01-31 18:57:05 +00:00
|
|
|
property int channelPosition: -1
|
|
|
|
property string chatCategoryId: ""
|
2022-03-07 14:56:05 +00:00
|
|
|
property var emojiPopup
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2022-01-05 15:50:03 +00:00
|
|
|
signal displayProfilePopup(string publicKey)
|
2021-12-21 09:26:13 +00:00
|
|
|
signal displayGroupInfoPopup(string chatId)
|
|
|
|
signal requestAllHistoricMessages(string chatId)
|
|
|
|
signal unmuteChat(string chatId)
|
|
|
|
signal muteChat(string chatId)
|
|
|
|
signal markAllMessagesRead(string chatId)
|
|
|
|
signal clearChatHistory(string chatId)
|
2021-12-09 12:53:40 +00:00
|
|
|
signal downloadMessages(string file)
|
2022-01-25 12:09:27 +00:00
|
|
|
signal deleteCommunityChat(string chatId)
|
2021-12-21 09:26:13 +00:00
|
|
|
signal leaveChat(string chatId)
|
2022-02-15 21:00:05 +00:00
|
|
|
signal leaveGroup(string chatId)
|
2022-07-12 08:27:35 +00:00
|
|
|
signal updateGroupChatDetails(string chatId, string groupName, string groupColor, string groupImage)
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2022-03-10 19:28:37 +00:00
|
|
|
signal createCommunityChannel(string chatId, string newName, string newDescription, string newEmoji, string newColor)
|
|
|
|
signal editCommunityChannel(string chatId, string newName, string newDescription, string newEmoji, string newColor, string newCategory)
|
2022-02-15 21:00:05 +00:00
|
|
|
signal fetchMoreMessages(int timeFrame)
|
|
|
|
signal addRemoveGroupMember()
|
2021-07-06 09:42:51 +00:00
|
|
|
|
2022-05-13 17:11:02 +00:00
|
|
|
width: root.amIChatAdmin && (root.chatType === Constants.chatType.privateGroupChat) ? 207 : implicitWidth
|
|
|
|
|
2022-06-10 11:12:03 +00:00
|
|
|
ViewProfileMenuItem {
|
|
|
|
enabled: root.chatType === Constants.chatType.oneToOne
|
|
|
|
onTriggered: root.displayProfilePopup(root.chatId)
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuItem {
|
2022-06-10 11:12:03 +00:00
|
|
|
text: qsTr("View Members")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "group-chat"
|
2022-06-10 11:12:03 +00:00
|
|
|
enabled: root.chatType === Constants.chatType.privateGroupChat
|
|
|
|
onTriggered: root.displayGroupInfoPopup(root.chatId)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2022-05-13 17:11:02 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Add / remove from group")
|
|
|
|
icon.name: "add-to-dm"
|
|
|
|
enabled: root.amIChatAdmin && (root.chatType === Constants.chatType.privateGroupChat)
|
|
|
|
onTriggered: { root.addRemoveGroupMember() }
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuSeparator {
|
2022-06-10 11:12:03 +00:00
|
|
|
visible: root.chatType === Constants.chatType.oneToOne || root.chatType === Constants.chatType.privateGroupChat
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 17:23:43 +00:00
|
|
|
Action {
|
2022-03-10 22:08:33 +00:00
|
|
|
enabled: root.currentFleet === Constants.waku_prod ||
|
2022-06-10 11:12:03 +00:00
|
|
|
root.currentFleet === Constants.waku_test ||
|
2022-03-10 22:08:33 +00:00
|
|
|
root.currentFleet === Constants.status_test ||
|
|
|
|
root.currentFleet === Constants.status_prod
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Test WakuV2 - requestAllHistoricMessages")
|
2021-12-09 12:53:40 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.requestAllHistoricMessages(root.chatId)
|
|
|
|
}
|
2021-07-20 17:23:43 +00:00
|
|
|
}
|
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
StatusMenuItem {
|
2022-07-12 08:27:35 +00:00
|
|
|
text: qsTr("Edit name and image")
|
|
|
|
icon.name: "edit_pencil"
|
2022-03-21 20:51:54 +00:00
|
|
|
enabled: root.chatType === Constants.chatType.privateGroupChat
|
2022-02-15 21:00:05 +00:00
|
|
|
&& root.amIChatAdmin
|
|
|
|
onTriggered: {
|
2022-04-12 18:54:01 +00:00
|
|
|
Global.openPopup(renameGroupPopupComponent, {
|
2022-07-12 08:27:35 +00:00
|
|
|
activeGroupName: root.chatName,
|
|
|
|
activeGroupColor: root.chatColor
|
2022-02-15 21:00:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-12 18:54:01 +00:00
|
|
|
Component {
|
|
|
|
id: renameGroupPopupComponent
|
|
|
|
RenameGroupPopup {
|
2022-07-12 08:27:35 +00:00
|
|
|
onUpdateGroupChatDetails: {
|
|
|
|
root.updateGroupChatDetails(root.chatId, groupName, groupColor, groupImage)
|
2022-04-12 18:54:01 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-10 11:12:03 +00:00
|
|
|
MuteChatMenuItem {
|
|
|
|
muted: root.chatMuted
|
2021-07-06 09:42:51 +00:00
|
|
|
onTriggered: {
|
2021-12-09 12:53:40 +00:00
|
|
|
if(root.chatMuted)
|
|
|
|
root.unmuteChat(root.chatId)
|
|
|
|
else
|
|
|
|
root.muteChat(root.chatId)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2022-07-28 20:14:29 +00:00
|
|
|
objectName: "chatMarkAsReadMenuItem"
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Mark as Read")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "checkmark-circle"
|
2021-12-09 12:53:40 +00:00
|
|
|
onTriggered: {
|
2021-12-08 11:10:34 +00:00
|
|
|
root.markAllMessagesRead(root.chatId)
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
//TODO uncomment when implemented
|
|
|
|
// StatusPopupMenu {
|
|
|
|
// title: qsTr("Fetch messages")
|
|
|
|
// enabled: (root.chatType === Constants.chatType.oneToOne ||
|
|
|
|
// root.chatType === Constants.chatType.privateGroupChat)
|
|
|
|
// StatusMenuItem {
|
|
|
|
// text: "Last 24 hours"
|
|
|
|
// onTriggered: {
|
|
|
|
// root.fetchMoreMessages();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// StatusMenuItem {
|
|
|
|
// text: "Last 2 days"
|
|
|
|
// onTriggered: {
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// StatusMenuItem {
|
|
|
|
// text: "Last 3 days"
|
|
|
|
// onTriggered: {
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// StatusMenuItem {
|
|
|
|
// text: "Last 7 days"
|
|
|
|
// onTriggered: {
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuItem {
|
2022-08-15 17:16:01 +00:00
|
|
|
objectName: "clearHistoryMenuItem"
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Clear history")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "close-circle"
|
2021-12-09 12:53:40 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.clearChatHistory(root.chatId)
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2022-07-25 17:15:02 +00:00
|
|
|
objectName: "editChannelMenuItem"
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Edit Channel")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "edit"
|
2022-01-05 15:50:03 +00:00
|
|
|
enabled: root.isCommunityChat && root.amIChatAdmin
|
2021-12-21 09:26:13 +00:00
|
|
|
onTriggered: {
|
2021-12-23 21:06:27 +00:00
|
|
|
Global.openPopup(editChannelPopup, {
|
|
|
|
isEdit: true,
|
|
|
|
channelName: root.chatName,
|
2022-01-31 18:57:05 +00:00
|
|
|
channelDescription: root.chatDescription,
|
2022-03-07 14:56:05 +00:00
|
|
|
channelEmoji: root.chatEmoji,
|
2022-03-10 19:28:37 +00:00
|
|
|
channelColor: root.chatColor,
|
2022-01-31 18:57:05 +00:00
|
|
|
categoryId: root.chatCategoryId
|
2021-12-23 21:06:27 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: editChannelPopup
|
|
|
|
CreateChannelPopup {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
isEdit: true
|
2022-08-05 06:47:19 +00:00
|
|
|
isDeleteable: root.isCommunityChat
|
2022-03-07 14:56:05 +00:00
|
|
|
emojiPopup: root.emojiPopup
|
2021-12-23 21:06:27 +00:00
|
|
|
onCreateCommunityChannel: {
|
2022-03-10 19:28:37 +00:00
|
|
|
root.createCommunityChannel(root.chatId, chName, chDescription, chEmoji, chColor);
|
2021-12-23 21:06:27 +00:00
|
|
|
}
|
|
|
|
onEditCommunityChannel: {
|
2022-03-10 19:28:37 +00:00
|
|
|
root.editCommunityChannel(root.chatId, chName, chDescription, chEmoji, chColor,
|
|
|
|
chCategoryId);
|
2021-12-23 21:06:27 +00:00
|
|
|
}
|
2022-08-05 06:47:19 +00:00
|
|
|
onDeleteCommunityChannel: {
|
|
|
|
Global.openPopup(deleteChatConfirmationDialogComponent)
|
|
|
|
close()
|
|
|
|
}
|
2021-12-23 21:06:27 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-09-15 10:59:01 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Download")
|
2021-10-20 09:50:50 +00:00
|
|
|
enabled: localAccountSensitiveSettings.downloadChannelMessagesEnabled
|
2021-09-15 10:59:01 +00:00
|
|
|
icon.name: "download"
|
2022-08-01 18:34:31 +00:00
|
|
|
onTriggered: downloadDialog.open()
|
2021-09-15 10:59:01 +00:00
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuSeparator {
|
|
|
|
visible: deleteOrLeaveMenuItem.enabled
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2022-08-01 18:34:31 +00:00
|
|
|
objectName: "deleteOrLeaveMenuItem"
|
2021-07-06 09:42:51 +00:00
|
|
|
id: deleteOrLeaveMenuItem
|
2021-07-30 16:14:10 +00:00
|
|
|
text: {
|
2021-12-21 09:26:13 +00:00
|
|
|
if (root.isCommunityChat) {
|
2021-07-30 16:14:10 +00:00
|
|
|
return qsTr("Delete Channel")
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
if (root.chatType === Constants.chatType.privateGroupChat) {
|
|
|
|
return qsTr("Leave group")
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
return root.chatType === Constants.chatType.oneToOne ?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("Delete chat") :
|
|
|
|
qsTr("Leave chat")
|
2021-07-30 16:14:10 +00:00
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
icon.name: root.chatType === Constants.chatType.oneToOne || root.isCommunityChat ? "delete" : "arrow-right"
|
|
|
|
icon.width: root.chatType === Constants.chatType.oneToOne || root.isCommunityChat ? 18 : 14
|
|
|
|
iconRotation: root.chatType === Constants.chatType.oneToOne || root.isCommunityChat ? 0 : 180
|
2021-07-06 09:42:51 +00:00
|
|
|
|
|
|
|
type: StatusMenuItem.Type.Danger
|
|
|
|
onTriggered: {
|
2022-02-15 21:00:05 +00:00
|
|
|
if (root.chatType === Constants.chatType.privateGroupChat) {
|
|
|
|
root.leaveChat(root.chatId);
|
|
|
|
} else {
|
|
|
|
Global.openPopup(deleteChatConfirmationDialogComponent);
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2022-01-05 15:50:03 +00:00
|
|
|
enabled: !root.isCommunityChat || root.amIChatAdmin
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-09-15 10:59:01 +00:00
|
|
|
FileDialog {
|
2022-08-01 18:34:31 +00:00
|
|
|
id: downloadDialog
|
2021-09-15 10:59:01 +00:00
|
|
|
acceptLabel: qsTr("Save")
|
|
|
|
fileMode: FileDialog.SaveFile
|
|
|
|
title: qsTr("Download messages")
|
|
|
|
currentFile: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) + "/messages.json"
|
|
|
|
defaultSuffix: "json"
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-09-15 10:59:01 +00:00
|
|
|
onAccepted: {
|
2022-08-01 18:34:31 +00:00
|
|
|
root.downloadMessages(downloadDialog.currentFile)
|
2021-09-15 10:59:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
Component {
|
|
|
|
id: deleteChatConfirmationDialogComponent
|
|
|
|
ConfirmationDialog {
|
2022-08-01 18:34:31 +00:00
|
|
|
confirmButtonObjectName: "deleteChatConfirmationDialogDeleteButton"
|
2021-07-06 09:42:51 +00:00
|
|
|
btnType: "warn"
|
2021-12-21 09:26:13 +00:00
|
|
|
header.title: root.isCommunityChat ? qsTr("Delete #%1").arg(root.chatName) :
|
2021-12-09 12:53:40 +00:00
|
|
|
root.chatType === Constants.chatType.oneToOne ?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("Delete chat") :
|
|
|
|
qsTr("Leave chat")
|
2021-12-21 09:26:13 +00:00
|
|
|
confirmButtonLabel: root.isCommunityChat ? qsTr("Delete") : header.title
|
|
|
|
confirmationText: root.isCommunityChat ? qsTr("Are you sure you want to delete #%1 channel?").arg(root.chatName) :
|
2021-12-09 12:53:40 +00:00
|
|
|
root.chatType === Constants.chatType.oneToOne ?
|
2021-09-14 09:58:20 +00:00
|
|
|
qsTr("Are you sure you want to delete this chat?"):
|
2021-07-30 16:14:10 +00:00
|
|
|
qsTr("Are you sure you want to leave this chat?")
|
2021-12-21 09:26:13 +00:00
|
|
|
showCancelButton: root.isCommunityChat
|
2021-09-14 09:58:20 +00:00
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2021-09-14 09:58:20 +00:00
|
|
|
onCancelButtonClicked: {
|
|
|
|
close()
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
onConfirmButtonClicked: {
|
2022-01-18 15:56:57 +00:00
|
|
|
if(root.isCommunityChat)
|
2022-01-25 12:09:27 +00:00
|
|
|
root.deleteCommunityChat(root.chatId)
|
2021-12-21 09:26:13 +00:00
|
|
|
else
|
|
|
|
root.leaveChat(root.chatId)
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-12-21 09:26:13 +00:00
|
|
|
close()
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|