2021-06-15 19:34:36 +00:00
|
|
|
import QtQuick 2.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2021-10-14 20:30:51 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-14 20:30:51 +00:00
|
|
|
|
2021-09-24 11:26:29 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2021-10-14 20:30:51 +00:00
|
|
|
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.views 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.popups 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.views.chat 1.0
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
import "../controls"
|
|
|
|
import "../panels"
|
2021-10-21 09:20:42 +00:00
|
|
|
import "../popups"
|
2021-06-15 19:34:36 +00:00
|
|
|
|
|
|
|
Item {
|
2021-07-20 14:24:16 +00:00
|
|
|
id: root
|
2021-10-21 22:39:53 +00:00
|
|
|
width: parent.width
|
|
|
|
// Setting a height of 0 breaks the layout for when it comes back visible
|
|
|
|
// The Item never goes back to actually have a height or width
|
|
|
|
height: visible ? messageNotificationContent.height : 0.01
|
2021-06-15 19:34:36 +00:00
|
|
|
visible: {
|
|
|
|
if (hideReadNotifications && model.read) {
|
|
|
|
return false
|
|
|
|
}
|
2022-09-12 10:06:26 +00:00
|
|
|
return acCurrentActivityCategory === ActivityCenterPopup.ActivityCategory.All ||
|
|
|
|
(model.notificationType === Constants.activityCenterNotificationTypeMention && acCurrentActivityCategory === ActivityCenterPopup.ActivityCategory.Mentions) ||
|
|
|
|
(model.notificationType === Constants.activityCenterNotificationTypeOneToOne && acCurrentActivityCategory === ActivityCenterPopup.ActivityCategory.ContactRequests) ||
|
|
|
|
(model.notificationType === Constants.activityCenterNotificationTypeReply && acCurrentActivityCategory === ActivityCenterPopup.ActivityCategory.Replies)
|
2021-06-15 19:34:36 +00:00
|
|
|
}
|
2021-10-21 22:39:53 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
property var store
|
2022-09-12 10:06:26 +00:00
|
|
|
property int acCurrentActivityCategory
|
2022-01-13 21:41:43 +00:00
|
|
|
property var chatSectionModule
|
|
|
|
property int previousNotificationIndex
|
2022-05-10 16:04:25 +00:00
|
|
|
property bool hideReadNotifications
|
2022-01-13 21:41:43 +00:00
|
|
|
property string previousNotificationTimestamp
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
property int communityIndex: -1 //root.store.chatsModelInst.communities.joinedCommunities.getCommunityIndex(model.message.communityId)
|
2022-02-01 13:10:24 +00:00
|
|
|
property var messageContextMenu
|
2021-07-20 14:24:16 +00:00
|
|
|
function openProfile() {
|
2021-12-31 12:29:51 +00:00
|
|
|
Global.openProfilePopup(model.author)
|
2021-07-20 14:24:16 +00:00
|
|
|
}
|
2022-05-10 16:04:25 +00:00
|
|
|
signal activityCenterClose()
|
2021-07-20 14:24:16 +00:00
|
|
|
|
2022-04-07 07:44:49 +00:00
|
|
|
function reevaluateItemBadge() {
|
|
|
|
let details = root.store.getBadgeDetails(model.sectionId, model.chatId)
|
2022-05-13 15:35:14 +00:00
|
|
|
badge.isCommunity = (details.sType === "community")
|
2022-04-07 07:44:49 +00:00
|
|
|
badge.name = details.cName
|
|
|
|
badge.channelName = details.cName
|
|
|
|
badge.communityName = details.sName
|
|
|
|
badge.communityColor = details.sColor
|
|
|
|
badge.communityThumbnailImage = details.sImage
|
|
|
|
}
|
|
|
|
|
2021-07-20 14:24:16 +00:00
|
|
|
Component {
|
|
|
|
id: markReadBtnComponent
|
2021-09-24 11:26:29 +00:00
|
|
|
StatusFlatRoundButton {
|
2021-07-20 14:24:16 +00:00
|
|
|
id: markReadBtn
|
|
|
|
width: 32
|
|
|
|
height: 32
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.width: 24
|
|
|
|
icon.height: 24
|
2022-04-15 10:47:05 +00:00
|
|
|
icon.source: Style.svg("check-activity")
|
|
|
|
icon.color: model.read ? icon.disabledColor : "transparent"
|
2021-10-18 10:34:16 +00:00
|
|
|
color: "transparent"
|
2021-09-24 11:26:29 +00:00
|
|
|
tooltip.text: !model.read ?
|
|
|
|
qsTr("Mark as Read") :
|
|
|
|
qsTr("Mark as Unread")
|
|
|
|
tooltip.orientation: StatusToolTip.Orientation.Left
|
2021-10-18 10:34:16 +00:00
|
|
|
tooltip.x: -tooltip.width - Style.current.padding
|
|
|
|
tooltip.y: markReadBtn.height / 2 - height / 2 + 4
|
2021-09-24 11:26:29 +00:00
|
|
|
onClicked: {
|
2021-12-13 19:52:55 +00:00
|
|
|
if (!model.read) {
|
2022-01-13 21:41:43 +00:00
|
|
|
return root.store.activityCenterModuleInst.markActivityCenterNotificationRead(model.id, model.message.communityId, model.chatId, model.notificationType)
|
2021-12-13 19:52:55 +00:00
|
|
|
}
|
|
|
|
return root.store.activityCenterModuleInst.markActivityCenterNotificationUnread(model.id, model.message.communityId, model.message.chatId, model.notificationType)
|
2021-09-24 11:26:29 +00:00
|
|
|
}
|
2021-07-20 14:24:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: acceptRejectComponent
|
2021-10-01 15:58:36 +00:00
|
|
|
AcceptRejectOptionsButtonsPanel {
|
2021-07-20 14:24:16 +00:00
|
|
|
id: buttons
|
|
|
|
onAcceptClicked: {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// const setActiveChannel = root.store.chatsModelInst.channelView.setActiveChannel
|
|
|
|
// const chatId = model.message.chatId
|
|
|
|
// const messageId = model.message.messageId
|
2021-12-13 19:52:55 +00:00
|
|
|
root.store.activityCenterModuleInst.acceptActivityCenterNotification(model.id)
|
2021-12-13 14:24:21 +00:00
|
|
|
// root.store.chatsModelInst.activityNotificationList.acceptActivityCenterNotification(model.id)
|
|
|
|
// setActiveChannel(chatId)
|
|
|
|
// positionAtMessage(messageId)
|
2021-07-20 14:24:16 +00:00
|
|
|
}
|
2021-12-13 19:52:55 +00:00
|
|
|
onDeclineClicked: root.store.activityCenterModuleInst.dismissActivityCenterNotification(model.id)
|
2021-07-20 14:24:16 +00:00
|
|
|
onProfileClicked: root.openProfile()
|
|
|
|
onBlockClicked: {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// const pk = model.author
|
|
|
|
// blockContactConfirmationDialog.contactName = chatsModel.userNameOrAlias(pk)
|
|
|
|
// blockContactConfirmationDialog.contactAddress = pk
|
|
|
|
// blockContactConfirmationDialog.open()
|
2021-07-20 14:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
onBlockButtonClicked: {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// root.store.profileModuleInst.blockContact(blockContactConfirmationDialog.contactAddress)
|
2021-12-13 19:52:55 +00:00
|
|
|
root.store.activityCenterModuleInst.dismissActivityCenterNotification(model.id)
|
|
|
|
blockContactConfirmationDialog.close()
|
2021-07-20 14:24:16 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-15 19:34:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: messageNotificationContent
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
2021-10-01 15:58:36 +00:00
|
|
|
MessageView {
|
2021-06-15 19:34:36 +00:00
|
|
|
id: notificationMessage
|
|
|
|
anchors.right: undefined
|
2022-07-05 10:12:27 +00:00
|
|
|
rootStore: root.store
|
2022-01-13 21:41:43 +00:00
|
|
|
messageStore: root.store.messageStore
|
|
|
|
messageId: model.id
|
|
|
|
senderDisplayName: model.message.senderDisplayName
|
2022-07-05 10:12:27 +00:00
|
|
|
messageText: model.message.messageText
|
2022-01-13 21:41:43 +00:00
|
|
|
responseToMessageWithId: model.message.responseToMessageWithId
|
|
|
|
senderId: model.message.senderId
|
|
|
|
senderLocalName: model.message.senderLocalName
|
|
|
|
senderIcon: model.message.senderIcon
|
|
|
|
amISender: model.message.amISender
|
|
|
|
messageImage: model.message.messageImage
|
|
|
|
messageTimestamp: model.timestamp
|
|
|
|
messageOutgoingStatus: model.message.outgoingStatus
|
|
|
|
messageContentType: model.message.contentType
|
2022-06-28 18:11:18 +00:00
|
|
|
senderTrustStatus: model.message.senderTrustStatus
|
2022-01-13 21:41:43 +00:00
|
|
|
activityCenterMessage: true
|
2022-07-05 10:12:27 +00:00
|
|
|
activityCenterMessageRead: model.read
|
2022-02-01 13:10:24 +00:00
|
|
|
onImageClicked: Global.openImagePopup(image, root.messageContextMenu)
|
2022-01-13 21:41:43 +00:00
|
|
|
scrollToBottom: null
|
2022-07-05 10:12:27 +00:00
|
|
|
messageClickHandler: {
|
2022-01-13 21:41:43 +00:00
|
|
|
if (isProfileClick) {
|
|
|
|
return Global.openProfilePopup(model.message.senderId);
|
|
|
|
}
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2022-05-10 16:04:25 +00:00
|
|
|
activityCenterClose()
|
2022-03-08 12:38:12 +00:00
|
|
|
root.store.activityCenterModuleInst.switchTo(model.sectionId, model.chatId, model.id)
|
2022-01-13 21:41:43 +00:00
|
|
|
}
|
|
|
|
prevMessageIndex: root.previousNotificationIndex
|
|
|
|
prevMsgTimestamp: root.previousNotificationTimestamp
|
2021-06-15 19:34:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2021-07-20 14:24:16 +00:00
|
|
|
id: bottomBackdrop
|
|
|
|
visible: badge.visible
|
2021-06-15 19:34:36 +00:00
|
|
|
anchors.top: notificationMessage.bottom
|
|
|
|
anchors.bottom: badge.bottom
|
2021-07-20 14:24:16 +00:00
|
|
|
anchors.bottomMargin: visible ? -Style.current.smallPadding : 0
|
2021-06-15 19:34:36 +00:00
|
|
|
width: parent.width
|
|
|
|
color: model.read ? Style.current.transparent : Utils.setColorAlpha(Style.current.blue, 0.1)
|
2021-07-20 14:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
active: true
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 12
|
|
|
|
anchors.bottom: notificationMessage.bottom
|
|
|
|
anchors.bottomMargin: 14
|
|
|
|
z: 52
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-07-20 14:24:16 +00:00
|
|
|
sourceComponent: {
|
|
|
|
if (model.notificationType === Constants.activityCenterNotificationTypeOneToOne) {
|
|
|
|
return acceptRejectComponent
|
|
|
|
}
|
|
|
|
return markReadBtnComponent
|
|
|
|
}
|
2021-06-15 19:34:36 +00:00
|
|
|
}
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
ActivityChannelBadgePanel {
|
2021-06-15 19:34:36 +00:00
|
|
|
id: badge
|
2021-10-01 15:58:36 +00:00
|
|
|
anchors.top: notificationMessage.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 61 // TODO find a way to align with the text of the message
|
2021-07-20 14:24:16 +00:00
|
|
|
visible: model.notificationType !== Constants.activityCenterNotificationTypeOneToOne
|
2021-06-15 19:34:36 +00:00
|
|
|
notificationType: model.notificationType
|
2021-12-08 21:20:43 +00:00
|
|
|
profileImage: realChatType === Constants.chatType.oneToOne ? Global.getProfileImage(chatId) || "" : ""
|
2022-05-13 15:35:14 +00:00
|
|
|
repliedMessageContent: model.repliedMessage.messageText
|
|
|
|
repliedMessageId: model.message.responseToMessageWithId
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
onCommunityNameClicked: {
|
2022-04-07 07:44:49 +00:00
|
|
|
root.store.activityCenterModuleInst.switchTo(model.sectionId, "", "")
|
2022-05-10 16:04:25 +00:00
|
|
|
activityCenterClose();
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
|
|
|
onChannelNameClicked: {
|
2022-04-07 07:44:49 +00:00
|
|
|
root.store.activityCenterModuleInst.switchTo(model.sectionId, model.chatId, "")
|
2022-05-10 16:04:25 +00:00
|
|
|
activityCenterClose();
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-06-15 19:34:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|