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
|
|
|
|
}
|
2021-10-01 15:58:36 +00:00
|
|
|
return activityCenter.currentFilter === ActivityCenterPopup.Filter.All ||
|
|
|
|
(model.notificationType === Constants.activityCenterNotificationTypeMention && activityCenter.currentFilter === ActivityCenterPopup.Filter.Mentions) ||
|
|
|
|
(model.notificationType === Constants.activityCenterNotificationTypeOneToOne && activityCenter.currentFilter === ActivityCenterPopup.Filter.ContactRequests) ||
|
|
|
|
(model.notificationType === Constants.activityCenterNotificationTypeReply && activityCenter.currentFilter === ActivityCenterPopup.Filter.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
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
property int communityIndex: -1 //root.store.chatsModelInst.communities.joinedCommunities.getCommunityIndex(model.message.communityId)
|
2021-07-20 14:24:16 +00:00
|
|
|
function openProfile() {
|
|
|
|
const pk = model.author
|
|
|
|
const userProfileImage = appMain.getProfileImage(pk)
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// openProfilePopup(root.store.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
|
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
|
|
|
|
icon.source: Style.svg("double-check")
|
|
|
|
color: "transparent"
|
|
|
|
//% "Mark as Read"
|
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 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// if (!model.read) {
|
|
|
|
// return root.store.chatsModelInst.activityNotificationList.markActivityCenterNotificationRead(model.id, model.message.communityId, model.message.chatId, model.notificationType)
|
|
|
|
// }
|
|
|
|
// return root.store.chatsModelInst.activityNotificationList.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
|
|
|
|
// root.store.profileModuleInst.addContact(model.author)
|
|
|
|
// root.store.chatsModelInst.activityNotificationList.acceptActivityCenterNotification(model.id)
|
|
|
|
// setActiveChannel(chatId)
|
|
|
|
// positionAtMessage(messageId)
|
2021-07-20 14:24:16 +00:00
|
|
|
}
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// onDeclineClicked: root.store.chatsModelInst.activityNotificationList.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)
|
|
|
|
// root.store.chatsModelInst.activityNotificationList.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
|
2021-12-09 12:53:40 +00:00
|
|
|
// rootStore: root.store
|
|
|
|
// messageStore: root.store.messageStore
|
2021-10-01 15:58:36 +00:00
|
|
|
//TODO Remove
|
2021-12-09 12:53:40 +00:00
|
|
|
// fromAuthor: model.message.fromAuthor
|
|
|
|
// chatId: model.message.chatId
|
|
|
|
// userName: model.message.userName
|
|
|
|
// alias: model.message.alias
|
|
|
|
// localName: model.message.localName
|
|
|
|
// message: model.message.message
|
|
|
|
// plainText: model.message.plainText
|
|
|
|
// identicon: model.message.identicon
|
|
|
|
// isCurrentUser: model.message.isCurrentUser
|
|
|
|
// timestamp: model.message.timestamp
|
|
|
|
// sticker: model.message.sticker
|
|
|
|
// contentType: model.message.contentType
|
|
|
|
// outgoingStatus: model.message.outgoingStatus
|
|
|
|
// responseTo: model.message.responseTo
|
|
|
|
// imageClick: imagePopup.openPopup.bind(imagePopup)
|
|
|
|
// messageId: model.message.messageId
|
|
|
|
// linkUrls: model.message.linkUrls
|
|
|
|
// communityId: model.message.communityId
|
|
|
|
// hasMention: model.message.hasMention
|
|
|
|
// stickerPackId: model.message.stickerPackId
|
|
|
|
// pinnedBy: model.message.pinnedBy
|
|
|
|
// pinnedMessage: model.message.isPinned
|
|
|
|
// activityCenterMessage: true
|
|
|
|
// read: model.read
|
|
|
|
// clickMessage: function (isProfileClick) {
|
|
|
|
// if (isProfileClick) {
|
|
|
|
// const pk = model.message.fromAuthor
|
|
|
|
// const userProfileImage = appMain.getProfileImage(pk)
|
|
|
|
// return openProfilePopup(root.store.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || root.store.utilsModelInst.generateIdenticon(pk))
|
|
|
|
// }
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// activityCenter.close()
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// if (model.message.communityId) {
|
|
|
|
// root.store.chatsModelInst.communities.setActiveCommunity(model.message.communityId)
|
|
|
|
// }
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// root.store.chatsModelInst.channelView.setActiveChannel(model.message.chatId)
|
|
|
|
// positionAtMessage(model.message.messageId)
|
|
|
|
// }
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// prevMessageIndex: previousNotificationIndex
|
|
|
|
// prevMsgTimestamp: previousNotificationTimestamp
|
|
|
|
// Component.onCompleted: {
|
|
|
|
// messageStore.activityCenterMessage = true;
|
|
|
|
// messageStore.fromAuthor = model.message.fromAuthor;
|
|
|
|
// messageStore.chatId = model.message.chatId;
|
|
|
|
// messageStore.userName = model.message.userName;
|
|
|
|
// messageStore.alias = model.message.alias;
|
|
|
|
// messageStore.localName = model.message.localName;
|
|
|
|
// messageStore.message = model.message.message;
|
|
|
|
// messageStore.plainText = model.message.plainText;
|
|
|
|
// messageStore.identicon = model.message.identicon;
|
|
|
|
// messageStore.isCurrentUser = model.message.isCurrentUser;
|
|
|
|
// messageStore.timestamp = model.message.timestamp;
|
|
|
|
// messageStore.sticker = model.message.sticker;
|
|
|
|
// messageStore.contentType = model.message.contentType;
|
|
|
|
// messageStore.outgoingStatus = model.message.outgoingStatus;
|
|
|
|
// messageStore.responseTo = model.message.responseTo;
|
|
|
|
// messageStore.imageClick = imagePopup.openPopup.bind(imagePopup);
|
|
|
|
// messageStore.messageId = model.message.messageId;
|
|
|
|
// messageStore.linkUrls = model.message.linkUrls;
|
|
|
|
// messageStore.communityId = model.message.communityId;
|
|
|
|
// messageStore.hasMention = model.message.hasMention;
|
|
|
|
// messageStore.stickerPackId = model.message.stickerPackId;
|
|
|
|
// messageStore.pinnedBy = model.message.pinnedBy;
|
|
|
|
// messageStore.pinnedMessage = model.message.isPinned;
|
|
|
|
// messageStore.read = model.read;
|
|
|
|
// messageStore.prevMessageIndex = previousNotificationIndex;
|
|
|
|
// messageStore.prevMsgTimestamp = previousNotificationTimestamp;
|
|
|
|
// messageStore.clickMessage = function (isProfileClick) {
|
|
|
|
// if (isProfileClick) {
|
|
|
|
// const pk = model.message.fromAuthor
|
|
|
|
// const userProfileImage = appMain.getProfileImage(pk)
|
|
|
|
// return openProfilePopup(root.store.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || root.store.utilsModelInst.generateIdenticon(pk))
|
|
|
|
// }
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// activityCenter.close()
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// if (model.message.communityId) {
|
|
|
|
// root.store.chatsModelInst.communities.setActiveCommunity(model.message.communityId)
|
|
|
|
// }
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// root.store.chatsModelInst.channelView.setActiveChannel(model.message.chatId)
|
|
|
|
// positionAtMessage(model.message.messageId)
|
|
|
|
// }
|
|
|
|
// }
|
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-10-01 15:58:36 +00:00
|
|
|
|
2021-06-15 19:34:36 +00:00
|
|
|
name: model.name
|
|
|
|
chatId: model.chatId
|
|
|
|
notificationType: model.notificationType
|
|
|
|
communityId: model.message.communityId
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// replyMessageIndex: root.store.chatsModelInst.messageView.getMessageIndex(model.chatId, model.responseTo)
|
|
|
|
// Not Refactored Yet
|
|
|
|
// repliedMessageContent: replyMessageIndex > -1 ? root.store.chatsModelInst.messageView.getMessageData(chatId, replyMessageIndex, "message") : ""
|
2021-10-01 15:58:36 +00:00
|
|
|
realChatType: {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// var chatType = root.store.chatsModelInst.channelView.chats.getChannelType(model.chatId)
|
|
|
|
// if (chatType === Constants.chatType.communityChat) {
|
|
|
|
// // TODO add a check for private community chats once it is created
|
|
|
|
// return Constants.chatType.publicChat
|
|
|
|
// }
|
|
|
|
// return chatType
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
profileImage: realChatType === Constants.chatType.oneToOne ? appMain.getProfileImage(chatId) || "" : ""
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// channelName: root.store.chatsModelInst.getChannelNameById(badge.chatId)
|
|
|
|
// Not Refactored Yet
|
|
|
|
// communityName: root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "name") : ""
|
|
|
|
// Not Refactored Yet
|
|
|
|
// communityThumbnailImage: root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "thumbnailImage") : ""
|
|
|
|
// Not Refactored Yet
|
|
|
|
// communityColor: !model.image && root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "communityColor"): ""
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
onCommunityNameClicked: {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// root.store.chatsModelInst.communities.setActiveCommunity(badge.communityId)
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
|
|
|
onChannelNameClicked: {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// root.store.chatsModelInst.communities.setActiveCommunity(badge.communityId)
|
|
|
|
// root.store.chatsModelInst.setActiveChannel(badge.chatId)
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2021-12-09 12:53:40 +00:00
|
|
|
enabled: badge.realChatType === Constants.chatType.oneToOne
|
2021-11-15 15:15:21 +00:00
|
|
|
target: root.store.allContacts
|
2021-10-01 15:58:36 +00:00
|
|
|
onContactChanged: {
|
|
|
|
if (pubkey === badge.chatId) {
|
|
|
|
badge.profileImage = appMain.getProfileImage(badge.chatId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-15 19:34:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|