2021-05-28 17:35:21 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2021-06-11 17:41:59 +00:00
|
|
|
import QtQml.Models 2.13
|
2021-07-29 19:20:49 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2022-07-13 12:29:38 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
2021-12-21 20:52:17 +00:00
|
|
|
import shared.popups 1.0
|
2022-07-26 14:23:45 +00:00
|
|
|
import shared.views.chat 1.0
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import utils 1.0
|
2021-10-18 10:56:05 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
import "../views"
|
|
|
|
import "../panels"
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2021-05-28 17:35:21 +00:00
|
|
|
Popup {
|
2022-07-26 14:23:45 +00:00
|
|
|
id: root
|
|
|
|
|
2022-09-12 10:06:26 +00:00
|
|
|
enum ActivityCategory {
|
2021-05-28 17:35:21 +00:00
|
|
|
All,
|
2022-09-12 10:06:26 +00:00
|
|
|
Admin,
|
2021-05-28 17:35:21 +00:00
|
|
|
Mentions,
|
|
|
|
Replies,
|
2022-09-12 10:06:26 +00:00
|
|
|
ContactRequests,
|
|
|
|
IdentityVerification,
|
|
|
|
Transactions,
|
|
|
|
Membership,
|
|
|
|
System
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
2022-09-12 10:06:26 +00:00
|
|
|
property int currentActivityCategory: ActivityCenterPopup.ActivityCategory.All
|
2021-06-11 19:50:52 +00:00
|
|
|
property bool hasMentions: false
|
|
|
|
property bool hasReplies: false
|
2021-07-27 17:59:01 +00:00
|
|
|
// property bool hasContactRequests: false
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2021-06-10 15:15:38 +00:00
|
|
|
property bool hideReadNotifications: false
|
2021-10-01 15:58:36 +00:00
|
|
|
property var store
|
2022-01-13 21:41:43 +00:00
|
|
|
property var chatSectionModule
|
2022-07-26 14:23:45 +00:00
|
|
|
property var messageContextMenu: MessageContextMenuView {
|
|
|
|
store: root.store
|
|
|
|
reactionModel: root.store.emojiReactionsModel
|
|
|
|
}
|
2021-06-10 15:15:38 +00:00
|
|
|
|
2022-07-26 14:23:45 +00:00
|
|
|
readonly property int unreadNotificationsCount : root.store.activityCenterList.unreadCount
|
2022-05-19 12:33:17 +00:00
|
|
|
|
2021-07-29 19:20:49 +00:00
|
|
|
modal: false
|
2021-05-28 17:35:21 +00:00
|
|
|
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
parent: Overlay.overlay
|
2021-07-29 19:20:49 +00:00
|
|
|
|
2021-09-08 02:11:51 +00:00
|
|
|
dim: true
|
2022-08-05 13:57:06 +00:00
|
|
|
Overlay.modeless: MouseArea {
|
|
|
|
onClicked: activityCenter.close()
|
|
|
|
}
|
2021-09-08 02:11:51 +00:00
|
|
|
|
2021-05-28 17:35:21 +00:00
|
|
|
width: 560
|
|
|
|
background: Rectangle {
|
|
|
|
color: Style.current.background
|
|
|
|
radius: Style.current.radius
|
2021-07-29 19:20:49 +00:00
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: Style.current.radius
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: Style.current.dropShadow
|
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
2022-07-26 14:23:45 +00:00
|
|
|
x: Global.applicationWindow.width - root.width - Style.current.halfPadding
|
2021-05-28 17:35:21 +00:00
|
|
|
onOpened: {
|
2021-12-08 21:20:43 +00:00
|
|
|
Global.popupOpened = true
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
onClosed: {
|
2021-12-08 21:20:43 +00:00
|
|
|
Global.popupOpened = false
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
padding: 0
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
ActivityCenterPopupTopBarPanel {
|
2021-05-28 17:35:21 +00:00
|
|
|
id: activityCenterTopBar
|
2022-09-12 10:06:26 +00:00
|
|
|
width: parent.width
|
2022-07-26 14:23:45 +00:00
|
|
|
hasReplies: root.hasReplies
|
|
|
|
hasMentions: root.hasMentions
|
|
|
|
hideReadNotifications: root.hideReadNotifications
|
2022-09-12 10:06:26 +00:00
|
|
|
currentActivityCategory: root.currentActivityCategory
|
|
|
|
onCategoryTriggered: {
|
|
|
|
root.currentActivityCategory = category;
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
|
|
|
onMarkAllReadClicked: {
|
2022-07-26 14:23:45 +00:00
|
|
|
errorText = root.store.activityCenterModuleInst.markAllActivityCenterNotificationsRead()
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2022-09-13 14:20:10 +00:00
|
|
|
// TODO: replace with StatusListView
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2021-06-11 17:41:59 +00:00
|
|
|
id: scrollView
|
2022-09-12 10:06:26 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2021-05-28 17:35:21 +00:00
|
|
|
anchors.top: activityCenterTopBar.bottom
|
|
|
|
anchors.topMargin: 13
|
2021-06-11 17:41:59 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Style.current.smallPadding
|
2021-05-28 17:35:21 +00:00
|
|
|
width: parent.width
|
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
2021-05-28 19:01:46 +00:00
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
Column {
|
|
|
|
id: notificationsContainer
|
2022-09-12 10:06:26 +00:00
|
|
|
width: scrollView.availableWidth
|
2021-06-11 17:41:59 +00:00
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: notifDelegateList
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
DelegateModelGeneralized {
|
|
|
|
id: notifDelegateList
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
lessThan: [
|
|
|
|
function(left, right) { return left.timestamp > right.timestamp }
|
|
|
|
]
|
|
|
|
|
2022-07-26 14:23:45 +00:00
|
|
|
model: root.store.activityCenterList
|
2021-06-11 17:41:59 +00:00
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
id: notificationDelegate
|
2022-09-12 10:06:26 +00:00
|
|
|
width: parent.availableWidth
|
2021-06-11 17:41:59 +00:00
|
|
|
height: notifLoader.active ? childrenRect.height : 0
|
|
|
|
|
|
|
|
property int idx: DelegateModel.itemsIndex
|
|
|
|
|
2021-06-11 19:50:52 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
switch (model.notificationType) {
|
2021-06-11 20:34:25 +00:00
|
|
|
case Constants.activityCenterNotificationTypeMention:
|
2021-06-11 19:50:52 +00:00
|
|
|
if (!hasMentions) {
|
|
|
|
hasMentions = true
|
|
|
|
}
|
|
|
|
break
|
|
|
|
|
2021-06-11 20:34:25 +00:00
|
|
|
case Constants.activityCenterNotificationTypeReply:
|
2021-06-11 19:50:52 +00:00
|
|
|
if (!hasReplies) {
|
|
|
|
hasReplies = true
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
|
|
|
|
Loader {
|
2021-06-15 19:34:36 +00:00
|
|
|
property int previousNotificationIndex: {
|
|
|
|
if (notificationDelegate.idx === 0) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is used in order to have access to the previous message and determine the timestamp
|
|
|
|
// we can't rely on the index because the sequence of messages is not ordered on the nim side
|
|
|
|
if (notificationDelegate.idx < notifDelegateList.items.count - 1) {
|
|
|
|
return notifDelegateList.items.get(notificationDelegate.idx - 1).model.index
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2022-09-12 10:06:26 +00:00
|
|
|
readonly property string previousNotificationTimestamp: notificationDelegate.idx === 0 ? "" :
|
|
|
|
root.store.activityCenterList.getNotificationData(previousNotificationIndex, "timestamp")
|
2021-10-01 15:58:36 +00:00
|
|
|
onPreviousNotificationTimestampChanged: {
|
2022-07-26 14:23:45 +00:00
|
|
|
root.store.messageStore.prevMsgTimestamp = previousNotificationTimestamp;
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
id: notifLoader
|
|
|
|
anchors.top: parent.top
|
|
|
|
active: !!sourceComponent
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: {
|
|
|
|
switch (model.notificationType) {
|
2021-07-20 14:24:16 +00:00
|
|
|
case Constants.activityCenterNotificationTypeOneToOne:
|
|
|
|
case Constants.activityCenterNotificationTypeMention:
|
2021-06-11 20:34:25 +00:00
|
|
|
case Constants.activityCenterNotificationTypeReply: return messageNotificationComponent
|
2021-06-15 19:34:36 +00:00
|
|
|
case Constants.activityCenterNotificationTypeGroupRequest: return groupRequestNotificationComponent
|
2021-06-11 17:41:59 +00:00
|
|
|
default: return null
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 21:41:43 +00:00
|
|
|
onLoaded: {
|
|
|
|
if (model.notificationType === Constants.activityCenterNotificationTypeReply ||
|
|
|
|
model.notificationType === Constants.activityCenterNotificationTypeGroupRequest) {
|
|
|
|
item.previousNotificationIndex = Qt.binding(() => notifLoader.previousNotificationIndex);
|
|
|
|
item.previousNotificationTimestamp = Qt.binding(() => notifLoader.previousNotificationTimestamp);
|
|
|
|
}
|
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: messageNotificationComponent
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
ActivityCenterMessageComponentView {
|
2022-04-07 07:44:49 +00:00
|
|
|
id: activityCenterMessageView
|
2022-07-26 14:23:45 +00:00
|
|
|
store: root.store
|
2022-09-12 10:06:26 +00:00
|
|
|
acCurrentActivityCategory: root.currentActivityCategory
|
2022-07-26 14:23:45 +00:00
|
|
|
chatSectionModule: root.chatSectionModule
|
|
|
|
messageContextMenu: root.messageContextMenu
|
|
|
|
hideReadNotifications: root.hideReadNotifications
|
2022-04-07 07:44:49 +00:00
|
|
|
Connections {
|
2022-07-26 14:23:45 +00:00
|
|
|
target: root
|
2022-04-07 07:44:49 +00:00
|
|
|
onOpened: activityCenterMessageView.reevaluateItemBadge()
|
|
|
|
}
|
2022-05-10 16:04:25 +00:00
|
|
|
onActivityCenterClose: {
|
2022-07-26 14:23:45 +00:00
|
|
|
root.close();
|
2022-05-10 16:04:25 +00:00
|
|
|
}
|
2022-04-07 07:44:49 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
activityCenterMessageView.reevaluateItemBadge()
|
|
|
|
}
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-06-15 19:34:36 +00:00
|
|
|
}
|
2021-06-21 15:03:40 +00:00
|
|
|
|
2021-06-15 19:34:36 +00:00
|
|
|
Component {
|
|
|
|
id: groupRequestNotificationComponent
|
2021-06-21 15:03:40 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
ActivityCenterGroupRequest {
|
2022-07-26 14:23:45 +00:00
|
|
|
store: root.store
|
|
|
|
hideReadNotifications: root.hideReadNotifications
|
2022-09-12 10:06:26 +00:00
|
|
|
acCurrentActivityCategoryAll: root.currentActivityCategory === ActivityCenter.ActivityCategory.All
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 18:05:49 +00:00
|
|
|
Item {
|
2022-07-26 14:23:45 +00:00
|
|
|
visible: root.store.activityCenterModuleInst.hasMoreToShow
|
2021-06-08 18:05:49 +00:00
|
|
|
width: parent.width
|
|
|
|
height: visible ? showMoreBtn.height + showMoreBtn.anchors.topMargin : 0
|
|
|
|
StatusButton {
|
|
|
|
id: showMoreBtn
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Show more")
|
2021-06-08 18:05:49 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2022-07-26 14:23:45 +00:00
|
|
|
onClicked: root.store.activityCenterModuleInst.loadMoreNotifications()
|
2021-06-08 18:05:49 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
}
|