fix(ActivityCenter): fix calculating AC notification types

Close #7361
This commit is contained in:
MishkaRogachev 2022-09-19 16:16:48 +03:00 committed by Mikhail Rogachev
parent 2d02a3cb2e
commit 91d80541be
3 changed files with 39 additions and 72 deletions

View File

@ -86,7 +86,7 @@ QtObject:
if (receivedData.activityCenterNotifications.len > 0):
self.events.emit(
SIGNAL_ACTIVITY_CENTER_NOTIFICATIONS_LOADED,
ActivityCenterNotificationsArgs(activityCenterNotifications: receivedData.activityCenterNotifications.filter(n => n.notificationType != ActivityCenterNotificationType.ContactRequest))
ActivityCenterNotificationsArgs(activityCenterNotifications: receivedData.activityCenterNotifications)
)
proc hasMoreToShow*(self: Service): bool =

View File

@ -62,6 +62,19 @@ Popup {
}
}
function calcNotificationType(notificationType, cnt) {
switch (notificationType) {
case Constants.activityCenterNotificationTypeMention:
root.mentionsCount += cnt
case Constants.activityCenterNotificationTypeReply:
root.repliesCount += cnt
case Constants.activityCenterNotificationTypeContactRequest:
root.contactRequestsCount += cnt
default:
break;
}
}
onOpened: {
Global.popupOpened = true
}
@ -69,17 +82,18 @@ Popup {
Global.popupOpened = false
}
x: Global.applicationWindow.width - root.width - Style.current.halfPadding
width: 560
padding: 0
dim: true
modal: false
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
parent: Overlay.overlay
dim: true
Overlay.modeless: MouseArea {
onClicked: activityCenter.close()
}
width: 560
background: Rectangle {
color: Style.current.background
radius: Style.current.radius
@ -93,8 +107,16 @@ Popup {
color: Style.current.dropShadow
}
}
x: Global.applicationWindow.width - root.width - Style.current.halfPadding
padding: 0
Repeater {
id: notificationTypeCounter
model: root.store.activityCenterList
delegate: Item {
Component.onCompleted: calcNotificationType(model.notificationType, 1)
Component.onDestruction: calcNotificationType(model.notificationType, -1)
}
}
ActivityCenterPopupTopBarPanel {
id: activityCenterTopBar
@ -121,7 +143,8 @@ Popup {
model: SortFilterProxyModel {
sourceModel: root.store.activityCenterList
filters: ExpressionFilter { expression: filterActivityCategories(model.notificationType) && !(root.hideReadNotifications && model.read) }
filters: ExpressionFilter { expression: filterActivityCategories(model.notificationType) &&
!(root.hideReadNotifications && model.read) }
}
delegate: DelegateChooser {
@ -133,8 +156,7 @@ Popup {
ActivityNotificationMention {
store: root.store
notification: model
Component.onCompleted: root.mentionsCount++
Component.onDestruction: root.mentionsCount--
messageContextMenu: root.messageContextMenu
}
}
DelegateChoice {
@ -143,8 +165,7 @@ Popup {
ActivityNotificationReply {
store: root.store
notification: model
Component.onCompleted: root.repliesCount++
Component.onDestruction: root.repliesCount--
messageContextMenu: root.messageContextMenu
}
}
DelegateChoice {
@ -153,68 +174,9 @@ Popup {
ActivityNotificationContactRequest {
store: root.store
notification: model
Component.onCompleted: root.contactRequestsCount++
Component.onDestruction: root.contactRequestsCount--
messageContextMenu: root.messageContextMenu
}
}
}
}
}
// id: notifLoader
// anchors.top: parent.top
// active: !!sourceComponent
// width: parent.width
// sourceComponent: {
// switch (model.notificationType) {
// case Constants.activityCenterNotificationTypeOneToOne:
// case Constants.activityCenterNotificationTypeMention:
// case Constants.activityCenterNotificationTypeReply: return messageNotificationComponent
// case Constants.activityCenterNotificationTypeGroupRequest: return groupRequestNotificationComponent
// default: return null
// }
// }
// onLoaded: {
// if (model.notificationType === Constants.activityCenterNotificationTypeReply ||
// model.notificationType === Constants.activityCenterNotificationTypeGroupRequest) {
// item.previousNotificationIndex = Qt.binding(() => notifLoader.previousNotificationIndex);
// item.previousNotificationTimestamp = Qt.binding(() => notifLoader.previousNotificationTimestamp);
// }
// }
// }
// Component {
// id: messageNotificationComponent
// ActivityCenterMessageComponentView {
// id: activityCenterMessageView
// store: root.store
// acCurrentActivityCategory: root.currentActivityCategory
// chatSectionModule: root.chatSectionModule
// messageContextMenu: root.messageContextMenu
// hideReadNotifications: root.hideReadNotifications
// Connections {
// target: root
// onOpened: activityCenterMessageView.reevaluateItemBadge()
// }
// onActivityCenterClose: {
// root.close();
// }
// Component.onCompleted: {
// activityCenterMessageView.reevaluateItemBadge()
// }
// }
// }
// Component {
// id: groupRequestNotificationComponent
// ActivityCenterGroupRequest {
// store: root.store
// hideReadNotifications: root.hideReadNotifications
// acCurrentActivityCategoryAll: root.currentActivityCategory === ActivityCenter.ActivityCategory.All
// }
// }
// }
// }

View File

@ -12,6 +12,8 @@ import shared.views.chat 1.0
ActivityNotificationBase {
id: root
property var messageContextMenu
signal activityCenterClose()
height: Math.max(60, notificationMessage.height)
@ -22,14 +24,17 @@ ActivityNotificationBase {
anchors.left: parent.left
anchors.right: parent.right
z: -1
rootStore: root.store
messageStore: root.store.messageStore
messageContextMenu: root.messageContextMenu
messageId: notification.id
senderDisplayName: notification.message.senderDisplayName
messageText: notification.message.messageText
responseToMessageWithId: notification.message.responseToMessageWithId
senderId: notification.message.senderId
senderLocalName: notification.message.senderLocalName
senderOptionalName: notification.message.senderOptionalName
senderIcon: notification.message.senderIcon
amISender: notification.message.amISender
messageImage: notification.message.messageImage