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-07-06 09:42:51 +00:00
|
|
|
StatusPopupMenu {
|
2021-10-21 22:39:53 +00:00
|
|
|
id: root
|
2021-07-06 09:42:51 +00:00
|
|
|
property var chatItem
|
2021-10-21 22:39:53 +00:00
|
|
|
property var store
|
2021-12-09 16:25:38 +00:00
|
|
|
property var chatSectionModule
|
2021-11-26 15:37:57 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
property bool communityActive: false // root.store.chatsModelInst.communities.activeCommunity.active
|
2021-07-06 09:42:51 +00:00
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
id: viewProfileMenuItem
|
|
|
|
text: {
|
|
|
|
if (chatItem) {
|
|
|
|
switch (chatItem.chatType) {
|
|
|
|
case Constants.chatTypeOneToOne:
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "View Profile"
|
|
|
|
return qsTrId("view-profile")
|
2021-07-06 09:42:51 +00:00
|
|
|
case Constants.chatTypePrivateGroupChat:
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "View Group"
|
|
|
|
return qsTrId("view-group")
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
icon.name: "group-chat"
|
|
|
|
enabled: chatItem &&
|
|
|
|
(chatItem.chatType === Constants.chatTypeOneToOne ||
|
|
|
|
chatItem.chatType === Constants.chatTypePrivateGroupChat)
|
|
|
|
onTriggered: {
|
|
|
|
if (chatItem.chatType === Constants.chatTypeOneToOne) {
|
|
|
|
const userProfileImage = appMain.getProfileImage(chatItem.id)
|
|
|
|
return openProfilePopup(
|
2021-07-13 11:56:52 +00:00
|
|
|
chatItem.name,
|
|
|
|
chatItem.id,
|
|
|
|
userProfileImage || chatItem.identicon,
|
|
|
|
"",
|
|
|
|
chatItem.name
|
2021-07-06 09:42:51 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
if (chatItem.chatType === Constants.chatTypePrivateGroupChat) {
|
2021-12-07 20:33:12 +00:00
|
|
|
return Global.openPopup(groupInfoPopupComponent, {
|
2021-07-28 10:41:37 +00:00
|
|
|
channel: chatItem,
|
|
|
|
channelType: GroupInfoPopup.ChannelType.ContextChannel
|
|
|
|
})
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuSeparator {
|
|
|
|
visible: viewProfileMenuItem.enabled
|
|
|
|
}
|
|
|
|
|
2021-07-20 17:23:43 +00:00
|
|
|
|
|
|
|
Action {
|
2021-10-21 22:39:53 +00:00
|
|
|
enabled: root.store.profileModelInst.fleets.fleet == Constants.waku_prod || root.store.profileModelInst.fleets.fleet === Constants.waku_test
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Test WakuV2 - requestAllHistoricMessages"
|
|
|
|
text: qsTrId("test-wakuv2---requestallhistoricmessages")
|
2021-10-21 22:39:53 +00:00
|
|
|
onTriggered: root.store.chatsModelInst.requestAllHistoricMessages()
|
2021-07-20 17:23:43 +00:00
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
text: chatItem && chatItem.muted ?
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Unmute chat"
|
|
|
|
qsTrId("unmute-chat") :
|
|
|
|
//% "Mute chat"
|
|
|
|
qsTrId("mute-chat")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "notification"
|
|
|
|
enabled: chatItem && chatItem.chatType !== Constants.chatTypePrivateGroupChat
|
|
|
|
onTriggered: {
|
|
|
|
if (chatItem && chatItem.muted) {
|
2021-10-21 22:39:53 +00:00
|
|
|
return root.store.chatsModelInst.channelView.unmuteChatItem(chatItem.id)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
2021-10-21 22:39:53 +00:00
|
|
|
root.store.chatsModelInst.channelView.muteChatItem(chatItem.id)
|
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"
|
|
|
|
enabled: chatItem && chatItem.chatType !== Constants.chatTypePrivateGroupChat
|
2021-10-21 22:39:53 +00:00
|
|
|
onTriggered: root.store.chatsModelInst.channelView.markChatItemAsRead(chatItem.id)
|
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-10-21 22:39:53 +00:00
|
|
|
onTriggered: root.store.chatsModelInst.channelView.clearChatHistory(chatItem.id)
|
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"
|
2021-07-30 16:14:10 +00:00
|
|
|
enabled: communityActive &&
|
2021-10-21 22:39:53 +00:00
|
|
|
root.store.chatsModelInst.communities.activeCommunity.admin
|
2021-12-07 20:33:12 +00:00
|
|
|
onTriggered: Global.openPopup(editChannelPopup, {
|
2021-11-03 13:25:56 +00:00
|
|
|
store: root.store,
|
2021-10-21 22:39:53 +00:00
|
|
|
communityId: root.store.chatsModelInst.communities.activeCommunity.id,
|
2021-07-06 09:42:51 +00:00
|
|
|
channel: chatItem
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
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: {
|
|
|
|
if (communityActive) {
|
|
|
|
return qsTr("Delete Channel")
|
|
|
|
}
|
|
|
|
return chatItem && chatItem.chatType === Constants.chatTypeOneToOne ?
|
|
|
|
//% "Delete chat"
|
|
|
|
qsTrId("delete-chat") :
|
|
|
|
//% "Leave chat"
|
|
|
|
qsTrId("leave-chat")
|
|
|
|
}
|
|
|
|
icon.name: chatItem && chatItem.chatType === Constants.chatTypeOneToOne || communityActive ? "delete" : "arrow-right"
|
2021-08-27 09:38:14 +00:00
|
|
|
icon.width: chatItem && chatItem.chatType === Constants.chatTypeOneToOne || communityActive ? 18 : 14
|
|
|
|
iconRotation: chatItem && chatItem.chatType === Constants.chatTypeOneToOne || communityActive ? 0 : 180
|
2021-07-06 09:42:51 +00:00
|
|
|
|
|
|
|
type: StatusMenuItem.Type.Danger
|
|
|
|
onTriggered: {
|
2021-12-07 20:33:12 +00:00
|
|
|
Global.openPopup(deleteChatConfirmationDialogComponent)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
enabled: !communityActive || root.store.chatsModelInst.communities.activeCommunity.admin
|
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"
|
|
|
|
onAccepted: {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.store.chatsModelInst.messageView.downloadMessages(downdloadDialog.currentFile)
|
2021-09-15 10:59:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
Component {
|
|
|
|
id: deleteChatConfirmationDialogComponent
|
|
|
|
ConfirmationDialog {
|
2021-10-21 00:41:54 +00:00
|
|
|
property string chatId: !!chatItem ? chatItem.id : ""
|
2021-07-06 09:42:51 +00:00
|
|
|
btnType: "warn"
|
2021-11-03 13:51:38 +00:00
|
|
|
header.title: communityActive && chatItem ? qsTr("Delete #%1").arg(chatItem.name) :
|
2021-09-14 09:58:20 +00:00
|
|
|
chatItem && chatItem.chatType === Constants.chatTypeOneToOne ?
|
|
|
|
//% "Delete chat"
|
|
|
|
qsTrId("delete-chat") :
|
|
|
|
//% "Leave chat"
|
|
|
|
qsTrId("leave-chat")
|
|
|
|
confirmButtonLabel: communityActive ? qsTr("Delete") : header.title
|
2021-11-03 13:51:38 +00:00
|
|
|
confirmationText: communityActive && chatItem ? qsTr("Are you sure you want to delete #%1 channel?").arg(chatItem.name) :
|
2021-09-14 09:58:20 +00:00
|
|
|
chatItem && chatItem.chatType === Constants.chatTypeOneToOne ?
|
|
|
|
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-09-14 09:58:20 +00:00
|
|
|
showCancelButton: communityActive
|
|
|
|
|
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: {
|
2021-07-30 16:14:10 +00:00
|
|
|
if (communityActive) {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.store.chatsModelInst.communities.deleteCommunityChat(root.store.chatsModelInst.communities.activeCommunity.id, chatId)
|
2021-07-30 16:14:10 +00:00
|
|
|
} else {
|
2021-12-09 16:25:38 +00:00
|
|
|
chatSectionModule.leaveChat(chatId)
|
2021-07-30 16:14:10 +00:00
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|