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"
|
2022-10-26 16:00:20 +00:00
|
|
|
import "../stores"
|
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-10-05 14:51:42 +00:00
|
|
|
property int adminCount: 0
|
2022-09-16 13:06:52 +00:00
|
|
|
property int mentionsCount: 0
|
|
|
|
property int repliesCount: 0
|
|
|
|
property int contactRequestsCount: 0
|
2022-10-05 14:51:42 +00:00
|
|
|
property int membershipCount: 0
|
2022-09-16 13:06:52 +00:00
|
|
|
|
2022-10-26 16:00:20 +00:00
|
|
|
property ActivityCenterStore activityCenterStore
|
2021-10-01 15:58:36 +00:00
|
|
|
property var store
|
2021-06-10 15:15:38 +00:00
|
|
|
|
2022-10-26 16:00:20 +00:00
|
|
|
readonly property int unreadNotificationsCount: root.activityCenterStore.unreadNotificationsCount
|
2022-09-15 16:34:41 +00:00
|
|
|
|
|
|
|
function filterActivityCategories(notificationType) {
|
|
|
|
switch (root.currentActivityCategory) {
|
|
|
|
case ActivityCenterPopup.ActivityCategory.All:
|
|
|
|
return true
|
2022-10-05 14:51:42 +00:00
|
|
|
case ActivityCenterPopup.ActivityCategory.Admin:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeCommunityMembershipRequest
|
2022-09-15 16:34:41 +00: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-10-05 14:51:42 +00:00
|
|
|
case ActivityCenterPopup.ActivityCategory.Membership:
|
|
|
|
return notificationType === Constants.activityCenterNotificationTypeCommunityInvitation ||
|
|
|
|
notificationType === Constants.activityCenterNotificationTypeCommunityMembershipRequest ||
|
2022-10-18 19:46:57 +00:00
|
|
|
notificationType === Constants.activityCenterNotificationTypeCommunityRequest ||
|
|
|
|
notificationType === Constants.activityCenterNotificationTypeCommunityKicked
|
2022-09-15 16:34:41 +00:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-19 13:16:48 +00:00
|
|
|
function calcNotificationType(notificationType, cnt) {
|
|
|
|
switch (notificationType) {
|
|
|
|
case Constants.activityCenterNotificationTypeMention:
|
2022-10-05 14:51:42 +00:00
|
|
|
root.mentionsCount += cnt;
|
2022-09-20 16:11:29 +00:00
|
|
|
break;
|
2022-09-19 13:16:48 +00:00
|
|
|
case Constants.activityCenterNotificationTypeReply:
|
2022-10-05 14:51:42 +00:00
|
|
|
root.repliesCount += cnt;
|
2022-09-20 16:11:29 +00:00
|
|
|
break;
|
2022-09-19 13:16:48 +00:00
|
|
|
case Constants.activityCenterNotificationTypeContactRequest:
|
2022-10-05 14:51:42 +00:00
|
|
|
root.contactRequestsCount += cnt;
|
|
|
|
break;
|
|
|
|
case Constants.activityCenterNotificationTypeCommunityInvitation:
|
|
|
|
root.membershipCount += cnt;
|
|
|
|
break;
|
|
|
|
case Constants.activityCenterNotificationTypeCommunityMembershipRequest:
|
2022-11-29 11:57:07 +00:00
|
|
|
// NOTE: not a typo, membership requests are shown in both categories
|
2022-10-05 14:51:42 +00:00
|
|
|
root.membershipCount += cnt;
|
|
|
|
root.adminCount += cnt;
|
|
|
|
break;
|
|
|
|
case Constants.activityCenterNotificationTypeCommunityRequest:
|
|
|
|
root.membershipCount += cnt;
|
2022-09-20 16:11:29 +00:00
|
|
|
break;
|
2022-10-18 19:46:57 +00:00
|
|
|
case Constants.ActivityCenterNotificationTypeCommunityKicked:
|
|
|
|
root.membershipCount += cnt;
|
|
|
|
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
|
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-11-29 11:57:07 +00:00
|
|
|
Overlay.modeless: null
|
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
|
2022-10-26 16:00:20 +00:00
|
|
|
model: root.activityCenterStore.activityCenterList
|
2022-09-19 13:16:48 +00:00
|
|
|
|
|
|
|
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
|
2022-10-05 14:51:42 +00:00
|
|
|
hasAdmin: root.adminCount > 0
|
2022-09-16 13:06:52 +00:00
|
|
|
hasReplies: root.repliesCount > 0
|
|
|
|
hasMentions: root.mentionsCount > 0
|
|
|
|
hasContactRequests: root.contactRequestsCount > 0
|
2022-10-05 14:51:42 +00:00
|
|
|
hasMembership: root.membershipCount > 0
|
2022-10-26 16:00:20 +00:00
|
|
|
hideReadNotifications: activityCenterStore.hideReadNotifications
|
2022-09-12 10:06:26 +00:00
|
|
|
currentActivityCategory: root.currentActivityCategory
|
2022-09-16 13:06:52 +00:00
|
|
|
onCategoryTriggered: root.currentActivityCategory = category
|
2022-10-26 16:00:20 +00:00
|
|
|
onMarkAllReadClicked: errorText = root.activityCenterStore.markAllActivityCenterNotificationsRead()
|
|
|
|
onShowHideReadNotifications: activityCenterStore.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
|
2022-10-29 07:17:35 +00:00
|
|
|
spacing: Style.current.padding
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
model: SortFilterProxyModel {
|
2022-10-26 16:00:20 +00:00
|
|
|
sourceModel: root.activityCenterStore.activityCenterList
|
2021-05-28 19:01:46 +00:00
|
|
|
|
2022-09-19 13:16:48 +00:00
|
|
|
filters: ExpressionFilter { expression: filterActivityCategories(model.notificationType) &&
|
2022-10-26 16:00:20 +00:00
|
|
|
!(activityCenterStore.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-11-23 14:50:00 +00:00
|
|
|
filteredIndex: index
|
2022-09-16 13:06:52 +00:00
|
|
|
store: root.store
|
2022-10-26 16:00:20 +00:00
|
|
|
activityCenterStore: root.activityCenterStore
|
2022-09-16 13:06:52 +00:00
|
|
|
notification: model
|
2022-11-16 17:17:38 +00:00
|
|
|
onCloseActivityCenter: 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-11-23 14:50:00 +00:00
|
|
|
filteredIndex: index
|
2022-09-16 13:06:52 +00:00
|
|
|
store: root.store
|
2022-10-26 16:00:20 +00:00
|
|
|
activityCenterStore: root.activityCenterStore
|
2022-09-16 13:06:52 +00:00
|
|
|
notification: model
|
2022-11-16 17:17:38 +00:00
|
|
|
onCloseActivityCenter: 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-11-23 14:50:00 +00:00
|
|
|
filteredIndex: index
|
2022-09-16 13:06:52 +00:00
|
|
|
store: root.store
|
2022-10-26 16:00:20 +00:00
|
|
|
activityCenterStore: root.activityCenterStore
|
2022-09-16 13:06:52 +00:00
|
|
|
notification: model
|
2022-11-16 17:17:38 +00:00
|
|
|
onCloseActivityCenter: root.close()
|
2022-09-16 13:06:52 +00:00
|
|
|
}
|
2021-06-08 18:05:49 +00:00
|
|
|
}
|
2022-10-05 14:51:42 +00:00
|
|
|
DelegateChoice {
|
|
|
|
roleValue: Constants.activityCenterNotificationTypeCommunityInvitation
|
|
|
|
|
|
|
|
ActivityNotificationCommunityInvitation {
|
|
|
|
width: listView.availableWidth
|
2022-11-23 14:50:00 +00:00
|
|
|
filteredIndex: index
|
2022-10-05 14:51:42 +00:00
|
|
|
store: root.store
|
2022-10-26 16:00:20 +00:00
|
|
|
activityCenterStore: root.activityCenterStore
|
2022-10-05 14:51:42 +00:00
|
|
|
notification: model
|
2022-11-16 17:17:38 +00:00
|
|
|
onCloseActivityCenter: root.close()
|
2022-10-05 14:51:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: Constants.activityCenterNotificationTypeCommunityMembershipRequest
|
|
|
|
|
|
|
|
ActivityNotificationCommunityMembershipRequest {
|
|
|
|
width: listView.availableWidth
|
2022-11-23 14:50:00 +00:00
|
|
|
filteredIndex: index
|
2022-10-05 14:51:42 +00:00
|
|
|
store: root.store
|
2022-10-26 16:00:20 +00:00
|
|
|
activityCenterStore: root.activityCenterStore
|
2022-10-05 14:51:42 +00:00
|
|
|
notification: model
|
2022-11-16 17:17:38 +00:00
|
|
|
onCloseActivityCenter: root.close()
|
2022-10-05 14:51:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: Constants.activityCenterNotificationTypeCommunityRequest
|
|
|
|
|
|
|
|
ActivityNotificationCommunityRequest {
|
|
|
|
width: listView.availableWidth
|
2022-11-23 14:50:00 +00:00
|
|
|
filteredIndex: index
|
2022-10-05 14:51:42 +00:00
|
|
|
store: root.store
|
2022-10-26 16:00:20 +00:00
|
|
|
activityCenterStore: root.activityCenterStore
|
2022-10-05 14:51:42 +00:00
|
|
|
notification: model
|
2022-11-16 17:17:38 +00:00
|
|
|
onCloseActivityCenter: root.close()
|
2022-10-05 14:51:42 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-18 19:46:57 +00:00
|
|
|
DelegateChoice {
|
|
|
|
roleValue: Constants.activityCenterNotificationTypeCommunityKicked
|
|
|
|
|
|
|
|
ActivityNotificationCommunityKicked {
|
|
|
|
width: listView.availableWidth
|
2022-11-23 14:50:00 +00:00
|
|
|
filteredIndex: index
|
2022-10-18 19:46:57 +00:00
|
|
|
store: root.store
|
2022-10-26 16:00:20 +00:00
|
|
|
activityCenterStore: root.activityCenterStore
|
2022-10-18 19:46:57 +00:00
|
|
|
notification: model
|
2022-11-16 17:17:38 +00:00
|
|
|
onCloseActivityCenter: root.close()
|
2022-10-18 19:46:57 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
}
|