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
|
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-04-12 18:54:01 +00:00
|
|
|
signal renameGroupChat(string chatId, string groupName)
|
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
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
id: viewProfileMenuItem
|
|
|
|
text: {
|
2021-12-09 12:53:40 +00:00
|
|
|
switch (root.chatType) {
|
|
|
|
case Constants.chatType.oneToOne:
|
|
|
|
//% "View Profile"
|
|
|
|
return qsTrId("view-profile")
|
|
|
|
case Constants.chatType.privateGroupChat:
|
2022-02-15 21:00:05 +00:00
|
|
|
return qsTr("View Members")
|
2021-12-09 12:53:40 +00:00
|
|
|
default:
|
|
|
|
return ""
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
icon.name: "group-chat"
|
2021-12-09 12:53:40 +00:00
|
|
|
enabled: root.chatType === Constants.chatType.oneToOne ||
|
|
|
|
root.chatType === Constants.chatType.privateGroupChat
|
2021-07-06 09:42:51 +00:00
|
|
|
onTriggered: {
|
2021-12-09 12:53:40 +00:00
|
|
|
if (root.chatType === Constants.chatType.oneToOne) {
|
2022-01-05 15:50:03 +00:00
|
|
|
root.displayProfilePopup(root.chatId)
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
|
|
|
if (root.chatType === Constants.chatType.privateGroupChat) {
|
|
|
|
root.displayGroupInfoPopup(root.chatId)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-12 18:54:01 +00:00
|
|
|
// TODO needs to be implemented
|
|
|
|
// This should open up the ad-hoc group chat creation view
|
|
|
|
// Design https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=417%3A243810
|
|
|
|
// StatusMenuItem {
|
|
|
|
// text: qsTr("Add / remove from group")
|
|
|
|
// icon.name: "notification"
|
|
|
|
// enabled: (root.chatType === Constants.chatType.privateGroupChat &&
|
|
|
|
// amIChatAdmin)
|
|
|
|
// onTriggered: {
|
|
|
|
// root.addRemoveGroupMember();
|
|
|
|
// }
|
|
|
|
// }
|
2022-02-15 21:00:05 +00:00
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuSeparator {
|
|
|
|
visible: viewProfileMenuItem.enabled
|
|
|
|
}
|
|
|
|
|
2021-07-20 17:23:43 +00:00
|
|
|
Action {
|
2022-03-10 22:08:33 +00:00
|
|
|
enabled: root.currentFleet === Constants.waku_prod ||
|
|
|
|
root.currentFleet === Constants.waku_test ||
|
|
|
|
root.currentFleet === Constants.status_test ||
|
|
|
|
root.currentFleet === Constants.status_prod
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Test WakuV2 - requestAllHistoricMessages"
|
|
|
|
text: qsTrId("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-04-12 18:54:01 +00:00
|
|
|
text: qsTr("Edit name")
|
2022-02-15 21:00:05 +00:00
|
|
|
icon.name: "edit"
|
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, {
|
|
|
|
activeChannelName: root.chatName,
|
2022-02-15 21:00:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-12 18:54:01 +00:00
|
|
|
Component {
|
|
|
|
id: renameGroupPopupComponent
|
|
|
|
RenameGroupPopup {
|
|
|
|
onDoRename: {
|
|
|
|
root.renameGroupChat(root.chatId, groupName)
|
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuItem {
|
2021-12-09 12:53:40 +00:00
|
|
|
text: root.chatMuted ?
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Unmute chat"
|
2022-02-09 09:43:23 +00:00
|
|
|
qsTrId("unmute-chat") :
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Mute chat"
|
|
|
|
qsTrId("mute-chat")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "notification"
|
|
|
|
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 {
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Mark as Read"
|
|
|
|
text: qsTrId("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 {
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Clear history"
|
|
|
|
text: qsTrId("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 {
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Edit Channel"
|
|
|
|
text: qsTrId("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-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
|
|
|
}
|
|
|
|
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"
|
|
|
|
onTriggered: downdloadDialog.open()
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuSeparator {
|
|
|
|
visible: deleteOrLeaveMenuItem.enabled
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
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 ?
|
2021-07-30 16:14:10 +00:00
|
|
|
//% "Delete chat"
|
|
|
|
qsTrId("delete-chat") :
|
|
|
|
//% "Leave chat"
|
|
|
|
qsTrId("leave-chat")
|
|
|
|
}
|
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 {
|
|
|
|
id: downdloadDialog
|
|
|
|
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: {
|
2021-12-09 12:53:40 +00:00
|
|
|
root.downloadMessages(downdloadDialog.currentFile)
|
2021-09-15 10:59:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
Component {
|
|
|
|
id: deleteChatConfirmationDialogComponent
|
|
|
|
ConfirmationDialog {
|
|
|
|
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 ?
|
2021-09-14 09:58:20 +00:00
|
|
|
//% "Delete chat"
|
|
|
|
qsTrId("delete-chat") :
|
|
|
|
//% "Leave chat"
|
|
|
|
qsTrId("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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|