2022-09-15 19:34:41 +03:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
2021-07-29 15:20:49 -04:00
|
|
|
import QtGraphicalEffects 1.13
|
2022-09-15 19:34:41 +03:00
|
|
|
import Qt.labs.qmlmodels 1.0
|
2022-07-13 15:29:38 +03:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2022-09-15 19:34:41 +03:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2021-10-28 00:27:49 +03:00
|
|
|
import shared 1.0
|
2021-12-21 22:52:17 +02:00
|
|
|
import shared.popups 1.0
|
2022-07-26 17:23:45 +03:00
|
|
|
import shared.views.chat 1.0
|
|
|
|
|
2022-07-13 15:29:38 +03:00
|
|
|
import utils 1.0
|
2021-10-18 12:56:05 +02:00
|
|
|
|
2021-10-01 18:58:36 +03:00
|
|
|
import "../views"
|
|
|
|
import "../panels"
|
2022-10-26 20:00:20 +04:00
|
|
|
import "../stores"
|
2021-09-28 18:04:06 +03:00
|
|
|
|
2021-05-28 13:35:21 -04:00
|
|
|
Popup {
|
2022-07-26 17:23:45 +03:00
|
|
|
id: root
|
|
|
|
|
2022-09-16 16:06:52 +03:00
|
|
|
// NOTE: temporary enum until we have different categories on UI and status-go sides
|
2022-09-12 14:06:26 +04:00
|
|
|
enum ActivityCategory {
|
2021-05-28 13:35:21 -04:00
|
|
|
All,
|
2022-09-12 14:06:26 +04:00
|
|
|
Admin,
|
2021-05-28 13:35:21 -04:00
|
|
|
Mentions,
|
|
|
|
Replies,
|
2022-09-12 14:06:26 +04:00
|
|
|
ContactRequests,
|
|
|
|
IdentityVerification,
|
|
|
|
Transactions,
|
|
|
|
Membership,
|
|
|
|
System
|
2021-05-28 13:35:21 -04:00
|
|
|
}
|
2022-09-12 14:06:26 +04:00
|
|
|
property int currentActivityCategory: ActivityCenterPopup.ActivityCategory.All
|
2022-10-05 18:51:42 +04:00
|
|
|
property int adminCount: 0
|
2022-09-16 16:06:52 +03:00
|
|
|
property int mentionsCount: 0
|
|
|
|
property int repliesCount: 0
|
|
|
|
property int contactRequestsCount: 0
|
2022-11-15 13:11:55 +03:00
|
|
|
property int identityRequestsCount: 0
|
2022-10-05 18:51:42 +04:00
|
|
|
property int membershipCount: 0
|
2022-09-16 16:06:52 +03:00
|
|
|
|
2022-10-26 20:00:20 +04:00
|
|
|
property ActivityCenterStore activityCenterStore
|
2021-10-01 18:58:36 +03:00
|
|
|
property var store
|
2021-06-10 11:15:38 -04:00
|
|
|
|
2022-10-26 20:00:20 +04:00
|
|
|
readonly property int unreadNotificationsCount: root.activityCenterStore.unreadNotificationsCount
|
2022-09-15 19:34:41 +03:00
|
|
|
|
|
|
|
function filterActivityCategories(notificationType) {
|
|
|
|
switch (root.currentActivityCategory) {
|
|
|
|
case ActivityCenterPopup.ActivityCategory.All:
|
|
|
|
return true
|
2022-10-05 18:51:42 +04:00
|
|
|
case ActivityCenterPopup.ActivityCategory.Admin:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeCommunityMembershipRequest
|
2022-09-15 19:34:41 +03:00
|
|
|
case ActivityCenterPopup.ActivityCategory.Mentions:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeMention
|
|
|
|
case ActivityCenterPopup.ActivityCategory.Replies:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeReply
|
|
|
|
case ActivityCenterPopup.ActivityCategory.ContactRequests:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeContactRequest
|
2022-11-15 13:11:55 +03:00
|
|
|
case ActivityCenterPopup.ActivityCategory.IdentityVerification:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeContactVerification
|
2022-10-05 18:51:42 +04:00
|
|
|
case ActivityCenterPopup.ActivityCategory.Membership:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeCommunityInvitation ||
|
|
|
|
notificationType === Constants.activityCenterNotificationTypeCommunityMembershipRequest ||
|
2022-10-18 23:46:57 +04:00
|
|
|
notificationType === Constants.activityCenterNotificationTypeCommunityRequest ||
|
|
|
|
notificationType === Constants.activityCenterNotificationTypeCommunityKicked
|
2022-09-15 19:34:41 +03:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-19 16:16:48 +03:00
|
|
|
function calcNotificationType(notificationType, cnt) {
|
|
|
|
switch (notificationType) {
|
|
|
|
case Constants.activityCenterNotificationTypeMention:
|
2022-10-05 18:51:42 +04:00
|
|
|
root.mentionsCount += cnt;
|
2022-09-20 19:11:29 +03:00
|
|
|
break;
|
2022-09-19 16:16:48 +03:00
|
|
|
case Constants.activityCenterNotificationTypeReply:
|
2022-10-05 18:51:42 +04:00
|
|
|
root.repliesCount += cnt;
|
2022-09-20 19:11:29 +03:00
|
|
|
break;
|
2022-09-19 16:16:48 +03:00
|
|
|
case Constants.activityCenterNotificationTypeContactRequest:
|
2022-10-05 18:51:42 +04:00
|
|
|
root.contactRequestsCount += cnt;
|
|
|
|
break;
|
2022-11-15 13:11:55 +03:00
|
|
|
case Constants.activityCenterNotificationTypeContactVerification:
|
|
|
|
root.identityRequestsCount += cnt;
|
|
|
|
break;
|
2022-10-05 18:51:42 +04:00
|
|
|
case Constants.activityCenterNotificationTypeCommunityInvitation:
|
|
|
|
root.membershipCount += cnt;
|
|
|
|
break;
|
|
|
|
case Constants.activityCenterNotificationTypeCommunityMembershipRequest:
|
2022-11-29 12:57:07 +01:00
|
|
|
// NOTE: not a typo, membership requests are shown in both categories
|
2022-10-05 18:51:42 +04:00
|
|
|
root.membershipCount += cnt;
|
|
|
|
root.adminCount += cnt;
|
|
|
|
break;
|
|
|
|
case Constants.activityCenterNotificationTypeCommunityRequest:
|
|
|
|
root.membershipCount += cnt;
|
2022-09-20 19:11:29 +03:00
|
|
|
break;
|
2022-10-18 23:46:57 +04:00
|
|
|
case Constants.ActivityCenterNotificationTypeCommunityKicked:
|
|
|
|
root.membershipCount += cnt;
|
|
|
|
break;
|
2022-09-19 16:16:48 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-15 19:34:41 +03:00
|
|
|
onOpened: {
|
|
|
|
Global.popupOpened = true
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
Global.popupOpened = false
|
|
|
|
}
|
2022-05-19 14:33:17 +02:00
|
|
|
|
2022-09-19 16:16:48 +03:00
|
|
|
x: Global.applicationWindow.width - root.width - Style.current.halfPadding
|
|
|
|
width: 560
|
|
|
|
padding: 0
|
2021-07-29 15:20:49 -04:00
|
|
|
modal: false
|
2021-05-28 13:35:21 -04:00
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
parent: Overlay.overlay
|
2021-07-29 15:20:49 -04:00
|
|
|
|
2022-11-29 12:57:07 +01:00
|
|
|
Overlay.modeless: null
|
2021-09-08 05:11:51 +03:00
|
|
|
|
2021-05-28 13:35:21 -04:00
|
|
|
background: Rectangle {
|
|
|
|
color: Style.current.background
|
|
|
|
radius: Style.current.radius
|
2021-07-29 15:20:49 -04: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 13:35:21 -04:00
|
|
|
}
|
2022-09-19 16:16:48 +03:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: notificationTypeCounter
|
2022-10-26 20:00:20 +04:00
|
|
|
model: root.activityCenterStore.activityCenterList
|
2022-09-19 16:16:48 +03:00
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
Component.onCompleted: calcNotificationType(model.notificationType, 1)
|
|
|
|
Component.onDestruction: calcNotificationType(model.notificationType, -1)
|
|
|
|
}
|
|
|
|
}
|
2021-05-28 13:35:21 -04:00
|
|
|
|
2021-10-01 18:58:36 +03:00
|
|
|
ActivityCenterPopupTopBarPanel {
|
2021-05-28 13:35:21 -04:00
|
|
|
id: activityCenterTopBar
|
2022-09-12 14:06:26 +04:00
|
|
|
width: parent.width
|
2022-09-16 16:06:52 +03:00
|
|
|
unreadNotificationsCount: root.unreadNotificationsCount
|
2022-10-05 18:51:42 +04:00
|
|
|
hasAdmin: root.adminCount > 0
|
2022-09-16 16:06:52 +03:00
|
|
|
hasReplies: root.repliesCount > 0
|
|
|
|
hasMentions: root.mentionsCount > 0
|
|
|
|
hasContactRequests: root.contactRequestsCount > 0
|
2022-11-15 13:11:55 +03:00
|
|
|
hasIdentityRequests: root.identityRequestsCount > 0
|
2022-10-05 18:51:42 +04:00
|
|
|
hasMembership: root.membershipCount > 0
|
2022-10-26 20:00:20 +04:00
|
|
|
hideReadNotifications: activityCenterStore.hideReadNotifications
|
2022-09-12 14:06:26 +04:00
|
|
|
currentActivityCategory: root.currentActivityCategory
|
2022-09-16 16:06:52 +03:00
|
|
|
onCategoryTriggered: root.currentActivityCategory = category
|
2023-01-12 23:39:46 +01:00
|
|
|
onMarkAllReadClicked: root.activityCenterStore.markAllActivityCenterNotificationsRead()
|
2022-10-26 20:00:20 +04:00
|
|
|
onShowHideReadNotifications: activityCenterStore.hideReadNotifications = hideReadNotifications
|
2021-05-28 13:35:21 -04:00
|
|
|
}
|
|
|
|
|
2022-09-15 19:34:41 +03:00
|
|
|
StatusListView {
|
|
|
|
id: listView
|
2022-09-12 14:06:26 +04:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2021-05-28 13:35:21 -04:00
|
|
|
anchors.top: activityCenterTopBar.bottom
|
2021-06-11 13:41:59 -04:00
|
|
|
anchors.bottom: parent.bottom
|
2022-09-15 19:34:41 +03:00
|
|
|
anchors.margins: Style.current.smallPadding
|
2023-01-23 13:00:06 +04:00
|
|
|
spacing: 1
|
2021-05-28 13:35:21 -04:00
|
|
|
|
2022-09-15 19:34:41 +03:00
|
|
|
model: SortFilterProxyModel {
|
2022-10-26 20:00:20 +04:00
|
|
|
sourceModel: root.activityCenterStore.activityCenterList
|
2021-05-28 15:01:46 -04:00
|
|
|
|
2022-09-19 16:16:48 +03:00
|
|
|
filters: ExpressionFilter { expression: filterActivityCategories(model.notificationType) &&
|
2022-10-26 20:00:20 +04:00
|
|
|
!(activityCenterStore.hideReadNotifications && model.read) }
|
2022-09-26 19:51:06 +04:00
|
|
|
|
|
|
|
sorters: [
|
|
|
|
RoleSorter {
|
|
|
|
roleName: "timestamp"
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
}
|
|
|
|
]
|
2022-09-15 19:34:41 +03:00
|
|
|
}
|
2021-06-11 13:41:59 -04:00
|
|
|
|
2022-11-30 15:15:29 +04:00
|
|
|
delegate: Loader {
|
|
|
|
width: listView.availableWidth
|
|
|
|
|
|
|
|
property int filteredIndex: index
|
|
|
|
property var notification: model
|
|
|
|
|
|
|
|
sourceComponent: {
|
|
|
|
switch (model.notificationType) {
|
|
|
|
case Constants.activityCenterNotificationTypeMention:
|
|
|
|
return mentionNotificationComponent
|
|
|
|
case Constants.activityCenterNotificationTypeReply:
|
|
|
|
return replyNotificationComponent
|
|
|
|
case Constants.activityCenterNotificationTypeContactRequest:
|
|
|
|
return contactRequestNotificationComponent
|
2022-11-15 13:11:55 +03:00
|
|
|
case Constants.activityCenterNotificationTypeContactVerification:
|
|
|
|
return verificationRequestNotificationComponent
|
2022-11-30 15:15:29 +04:00
|
|
|
case Constants.activityCenterNotificationTypeCommunityInvitation:
|
|
|
|
return communityInvitationNotificationComponent
|
|
|
|
case Constants.activityCenterNotificationTypeCommunityMembershipRequest:
|
|
|
|
return membershipRequestNotificationComponent
|
|
|
|
case Constants.activityCenterNotificationTypeCommunityRequest:
|
|
|
|
return communityRequestNotificationComponent
|
|
|
|
case Constants.activityCenterNotificationTypeCommunityKicked:
|
|
|
|
return communityKickedNotificationComponent
|
|
|
|
default:
|
|
|
|
return null
|
2022-10-18 23:46:57 +04:00
|
|
|
}
|
|
|
|
}
|
2021-06-11 13:41:59 -04:00
|
|
|
}
|
2021-05-28 13:35:21 -04:00
|
|
|
}
|
2022-11-30 15:15:29 +04:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: mentionNotificationComponent
|
|
|
|
|
|
|
|
ActivityNotificationMention {
|
|
|
|
filteredIndex: parent.filteredIndex
|
|
|
|
notification: parent.notification
|
|
|
|
store: root.store
|
|
|
|
activityCenterStore: root.activityCenterStore
|
|
|
|
onCloseActivityCenter: root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: replyNotificationComponent
|
|
|
|
|
|
|
|
ActivityNotificationReply {
|
|
|
|
filteredIndex: parent.filteredIndex
|
|
|
|
notification: parent.notification
|
|
|
|
store: root.store
|
|
|
|
activityCenterStore: root.activityCenterStore
|
|
|
|
onCloseActivityCenter: root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: contactRequestNotificationComponent
|
|
|
|
|
|
|
|
ActivityNotificationContactRequest {
|
|
|
|
filteredIndex: parent.filteredIndex
|
|
|
|
notification: parent.notification
|
|
|
|
store: root.store
|
|
|
|
activityCenterStore: root.activityCenterStore
|
|
|
|
onCloseActivityCenter: root.close()
|
|
|
|
}
|
|
|
|
}
|
2022-11-15 13:11:55 +03:00
|
|
|
Component {
|
|
|
|
id: verificationRequestNotificationComponent
|
|
|
|
|
|
|
|
ActivityNotificationContactVerification {
|
|
|
|
filteredIndex: parent.filteredIndex
|
|
|
|
notification: parent.notification
|
|
|
|
store: root.store
|
|
|
|
activityCenterStore: root.activityCenterStore
|
|
|
|
onCloseActivityCenter: root.close()
|
|
|
|
}
|
|
|
|
}
|
2022-11-30 15:15:29 +04:00
|
|
|
Component {
|
|
|
|
id: communityInvitationNotificationComponent
|
|
|
|
|
|
|
|
ActivityNotificationCommunityInvitation {
|
|
|
|
filteredIndex: parent.filteredIndex
|
|
|
|
notification: parent.notification
|
|
|
|
store: root.store
|
|
|
|
activityCenterStore: root.activityCenterStore
|
|
|
|
onCloseActivityCenter: root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: membershipRequestNotificationComponent
|
|
|
|
|
|
|
|
ActivityNotificationCommunityMembershipRequest {
|
|
|
|
filteredIndex: parent.filteredIndex
|
|
|
|
notification: parent.notification
|
|
|
|
store: root.store
|
|
|
|
activityCenterStore: root.activityCenterStore
|
|
|
|
onCloseActivityCenter: root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: communityRequestNotificationComponent
|
|
|
|
|
|
|
|
ActivityNotificationCommunityRequest {
|
|
|
|
filteredIndex: parent.filteredIndex
|
|
|
|
notification: parent.notification
|
|
|
|
store: root.store
|
|
|
|
activityCenterStore: root.activityCenterStore
|
|
|
|
onCloseActivityCenter: root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: communityKickedNotificationComponent
|
|
|
|
|
|
|
|
ActivityNotificationCommunityKicked {
|
|
|
|
filteredIndex: parent.filteredIndex
|
|
|
|
notification: parent.notification
|
|
|
|
store: root.store
|
|
|
|
activityCenterStore: root.activityCenterStore
|
|
|
|
onCloseActivityCenter: root.close()
|
|
|
|
}
|
|
|
|
}
|
2021-05-28 13:35:21 -04:00
|
|
|
}
|