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-07-06 09:42:51 +00:00
|
|
|
import "./"
|
|
|
|
import "../../../../shared"
|
2021-10-14 10:01:34 +00:00
|
|
|
import "../../../../shared/popups"
|
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
|
|
|
|
|
|
|
|
StatusPopupMenu {
|
|
|
|
|
|
|
|
property var chatItem
|
2021-07-30 16:14:10 +00:00
|
|
|
property bool communityActive: chatsModel.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-07-28 10:41:37 +00:00
|
|
|
return openPopup(groupInfoPopupComponent, {
|
|
|
|
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-07-30 16:14:10 +00:00
|
|
|
enabled: profileModel.fleets.fleet == Constants.waku_prod || profileModel.fleets.fleet === Constants.waku_test
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Test WakuV2 - requestAllHistoricMessages"
|
|
|
|
text: qsTrId("test-wakuv2---requestallhistoricmessages")
|
2021-07-20 17:23:43 +00:00
|
|
|
onTriggered: chatsModel.requestAllHistoricMessages()
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
return chatsModel.channelView.unmuteChatItem(chatItem.id)
|
|
|
|
}
|
|
|
|
chatsModel.channelView.muteChatItem(chatItem.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
onTriggered: chatsModel.channelView.markChatItemAsRead(chatItem.id)
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
onTriggered: chatsModel.channelView.clearChatHistory(chatItem.id)
|
|
|
|
}
|
|
|
|
|
|
|
|
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-07-06 09:42:51 +00:00
|
|
|
chatsModel.communities.activeCommunity.admin
|
|
|
|
onTriggered: openPopup(editChannelPopup, {
|
|
|
|
communityId: chatsModel.communities.activeCommunity.id,
|
|
|
|
channel: chatItem
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-09-15 10:59:01 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Download")
|
|
|
|
enabled: appSettings.downloadChannelMessagesEnabled
|
|
|
|
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-09-14 09:58:20 +00:00
|
|
|
openPopup(deleteChatConfirmationDialogComponent)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-07-30 16:14:10 +00:00
|
|
|
enabled: !communityActive || chatsModel.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: {
|
|
|
|
chatsModel.messageView.downloadMessages(downdloadDialog.currentFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
Component {
|
|
|
|
id: deleteChatConfirmationDialogComponent
|
|
|
|
ConfirmationDialog {
|
2021-09-14 09:58:20 +00:00
|
|
|
property string chatId: chatItem.id
|
2021-07-06 09:42:51 +00:00
|
|
|
btnType: "warn"
|
2021-09-14 09:58:20 +00:00
|
|
|
header.title: communityActive ? qsTr("Delete #%1").arg(chatItem.name) :
|
|
|
|
chatItem && chatItem.chatType === Constants.chatTypeOneToOne ?
|
|
|
|
//% "Delete chat"
|
|
|
|
qsTrId("delete-chat") :
|
|
|
|
//% "Leave chat"
|
|
|
|
qsTrId("leave-chat")
|
|
|
|
confirmButtonLabel: communityActive ? qsTr("Delete") : header.title
|
|
|
|
confirmationText: communityActive ? qsTr("Are you sure you want to delete #%1 channel?").arg(chatItem.name) :
|
|
|
|
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) {
|
|
|
|
chatsModel.communities.deleteCommunityChat(chatsModel.communities.activeCommunity.id, chatId)
|
|
|
|
} else {
|
|
|
|
chatsModel.channelView.leaveChat(chatId)
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|