2022-09-15 16:34:41 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
2021-07-29 19:20:49 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2022-09-15 16:34:41 +00:00
|
|
|
import Qt.labs.qmlmodels 1.0
|
2022-07-13 12:29:38 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
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-16 13:06:52 +00:00
|
|
|
// NOTE: temporary enum until we have different categories on UI and status-go sides
|
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
|
2022-09-16 13:06:52 +00:00
|
|
|
property int mentionsCount: 0
|
|
|
|
property int repliesCount: 0
|
|
|
|
property int contactRequestsCount: 0
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
property var store
|
2022-09-23 15:02:54 +00:00
|
|
|
property var acStore
|
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-09-15 16:34:41 +00:00
|
|
|
readonly property int unreadNotificationsCount : root.store.unreadNotificationsCount
|
|
|
|
|
|
|
|
function filterActivityCategories(notificationType) {
|
|
|
|
switch (root.currentActivityCategory) {
|
|
|
|
case ActivityCenterPopup.ActivityCategory.All:
|
|
|
|
return true
|
|
|
|
case ActivityCenterPopup.ActivityCategory.Mentions:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeMention
|
|
|
|
case ActivityCenterPopup.ActivityCategory.Replies:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeReply
|
|
|
|
case ActivityCenterPopup.ActivityCategory.ContactRequests:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeContactRequest
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-19 13:16:48 +00:00
|
|
|
function calcNotificationType(notificationType, cnt) {
|
|
|
|
switch (notificationType) {
|
|
|
|
case Constants.activityCenterNotificationTypeMention:
|
|
|
|
root.mentionsCount += cnt
|
2022-09-20 16:11:29 +00:00
|
|
|
break;
|
2022-09-19 13:16:48 +00:00
|
|
|
case Constants.activityCenterNotificationTypeReply:
|
|
|
|
root.repliesCount += cnt
|
2022-09-20 16:11:29 +00:00
|
|
|
break;
|
2022-09-19 13:16:48 +00:00
|
|
|
case Constants.activityCenterNotificationTypeContactRequest:
|
|
|
|
root.contactRequestsCount += cnt
|
2022-09-20 16:11:29 +00:00
|
|
|
break;
|
2022-09-19 13:16:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
onOpened: {
|
|
|
|
Global.popupOpened = true
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
Global.popupOpened = false
|
|
|
|
}
|
2022-05-19 12:33:17 +00:00
|
|
|
|
2022-09-19 13:16:48 +00:00
|
|
|
x: Global.applicationWindow.width - root.width - Style.current.halfPadding
|
|
|
|
width: 560
|
|
|
|
padding: 0
|
|
|
|
dim: true
|
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
|
|
|
|
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
|
|
|
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-09-19 13:16:48 +00:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: notificationTypeCounter
|
|
|
|
model: root.store.activityCenterList
|
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
Component.onCompleted: calcNotificationType(model.notificationType, 1)
|
|
|
|
Component.onDestruction: calcNotificationType(model.notificationType, -1)
|
|
|
|
}
|
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
|
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-09-16 13:06:52 +00:00
|
|
|
unreadNotificationsCount: root.unreadNotificationsCount
|
|
|
|
hasReplies: root.repliesCount > 0
|
|
|
|
hasMentions: root.mentionsCount > 0
|
|
|
|
hasContactRequests: root.contactRequestsCount > 0
|
2022-09-23 15:02:54 +00:00
|
|
|
hideReadNotifications: acStore.hideReadNotifications
|
2022-09-12 10:06:26 +00:00
|
|
|
currentActivityCategory: root.currentActivityCategory
|
2022-09-16 13:06:52 +00:00
|
|
|
onCategoryTriggered: root.currentActivityCategory = category
|
|
|
|
onMarkAllReadClicked: errorText = root.store.activityCenterModuleInst.markAllActivityCenterNotificationsRead()
|
2022-09-23 15:02:54 +00:00
|
|
|
onShowHideReadNotifications: acStore.hideReadNotifications = hideReadNotifications
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
StatusListView {
|
|
|
|
id: listView
|
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
|
2021-06-11 17:41:59 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2022-09-15 16:34:41 +00:00
|
|
|
anchors.margins: Style.current.smallPadding
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.store.activityCenterList
|
2021-05-28 19:01:46 +00:00
|
|
|
|
2022-09-19 13:16:48 +00:00
|
|
|
filters: ExpressionFilter { expression: filterActivityCategories(model.notificationType) &&
|
2022-09-23 15:02:54 +00:00
|
|
|
!(acStore.hideReadNotifications && model.read) }
|
2022-09-26 15:51:06 +00:00
|
|
|
|
|
|
|
sorters: [
|
|
|
|
RoleSorter {
|
|
|
|
roleName: "timestamp"
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
}
|
|
|
|
]
|
2022-09-15 16:34:41 +00:00
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
delegate: DelegateChooser {
|
|
|
|
role: "notificationType"
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
DelegateChoice {
|
|
|
|
roleValue: Constants.activityCenterNotificationTypeMention
|
2022-09-16 13:06:52 +00:00
|
|
|
|
|
|
|
ActivityNotificationMention {
|
2022-09-23 12:24:50 +00:00
|
|
|
width: listView.availableWidth
|
2022-09-16 13:06:52 +00:00
|
|
|
store: root.store
|
|
|
|
notification: model
|
2022-09-19 13:16:48 +00:00
|
|
|
messageContextMenu: root.messageContextMenu
|
2022-09-26 15:51:06 +00:00
|
|
|
previousNotificationIndex: Math.min(listView.count - 1, index + 1)
|
2022-09-20 16:11:29 +00:00
|
|
|
onActivityCenterClose: root.close()
|
2022-09-16 13:06:52 +00:00
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
2022-09-15 16:34:41 +00:00
|
|
|
DelegateChoice {
|
|
|
|
roleValue: Constants.activityCenterNotificationTypeReply
|
2022-09-16 13:06:52 +00:00
|
|
|
|
|
|
|
ActivityNotificationReply {
|
2022-09-23 12:24:50 +00:00
|
|
|
width: listView.availableWidth
|
2022-09-16 13:06:52 +00:00
|
|
|
store: root.store
|
|
|
|
notification: model
|
2022-09-19 13:16:48 +00:00
|
|
|
messageContextMenu: root.messageContextMenu
|
2022-09-26 15:51:06 +00:00
|
|
|
previousNotificationIndex: Math.min(listView.count - 1, index + 1)
|
2022-09-20 16:11:29 +00:00
|
|
|
onActivityCenterClose: root.close()
|
2022-09-16 13:06:52 +00:00
|
|
|
}
|
2022-09-15 16:34:41 +00:00
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: Constants.activityCenterNotificationTypeContactRequest
|
2022-09-16 13:06:52 +00:00
|
|
|
|
|
|
|
ActivityNotificationContactRequest {
|
2022-09-23 12:24:50 +00:00
|
|
|
width: listView.availableWidth
|
2022-09-16 13:06:52 +00:00
|
|
|
store: root.store
|
|
|
|
notification: model
|
2022-09-19 13:16:48 +00:00
|
|
|
messageContextMenu: root.messageContextMenu
|
2022-09-26 15:51:06 +00:00
|
|
|
previousNotificationIndex: Math.min(listView.count - 1, index + 1)
|
2022-09-20 16:11:29 +00:00
|
|
|
onActivityCenterClose: root.close()
|
2022-09-16 13:06:52 +00:00
|
|
|
}
|
2021-06-08 18:05:49 +00:00
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
}
|