feat(ActivityCenter): move activity category counters on the backend
This commit is contained in:
parent
bb9d6b3121
commit
a70bbd448c
|
@ -70,6 +70,7 @@ proc init*(self: Controller) =
|
|||
self.events.on(activity_center_service.SIGNAL_ACTIVITY_CENTER_NOTIFICATIONS_COUNT_MAY_HAVE_CHANGED) do(e: Args):
|
||||
self.delegate.unreadActivityCenterNotificationsCountChanged()
|
||||
self.delegate.hasUnseenActivityCenterNotificationsChanged()
|
||||
self.delegate.groupCountersChanged()
|
||||
|
||||
proc hasMoreToShow*(self: Controller): bool =
|
||||
return self.activityCenterService.hasMoreToShow()
|
||||
|
@ -158,3 +159,6 @@ proc setActivityCenterReadType*(self: Controller, readType: ActivityCenterReadTy
|
|||
|
||||
proc getActivityCenterReadType*(self: Controller): ActivityCenterReadType =
|
||||
return self.activityCenterService.getActivityCenterReadType()
|
||||
|
||||
proc getActivityGroupCounter*(self: Controller, group: ActivityCenterGroup): int =
|
||||
return self.activityCenterService.getActivityGroupCounter(group)
|
||||
|
|
|
@ -98,3 +98,24 @@ method setActivityCenterReadType*(self: AccessInterface, readType: int) {.base.}
|
|||
|
||||
method getActivityCenterReadType*(self: AccessInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method groupCountersChanged*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getAdminCount*(self: AccessInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getMentionsCount*(self: AccessInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getRepliesCount*(self: AccessInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getContactRequestsCount*(self: AccessInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getIdentityRequestsCount*(self: AccessInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getMembershipCount*(self: AccessInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -302,3 +302,24 @@ method setActivityCenterReadType*(self: Module, readType: int) =
|
|||
|
||||
method getActivityCenterReadType*(self: Module): int =
|
||||
return self.controller.getActivityCenterReadType().int
|
||||
|
||||
method groupCountersChanged*(self: Module) =
|
||||
self.view.groupCountersChanged()
|
||||
|
||||
method getAdminCount*(self: Module): int =
|
||||
return self.controller.getActivityGroupCounter(ActivityCenterGroup.Admin)
|
||||
|
||||
method getMentionsCount*(self: Module): int =
|
||||
return self.controller.getActivityGroupCounter(ActivityCenterGroup.Mentions)
|
||||
|
||||
method getRepliesCount*(self: Module): int =
|
||||
return self.controller.getActivityGroupCounter(ActivityCenterGroup.Replies)
|
||||
|
||||
method getContactRequestsCount*(self: Module): int =
|
||||
return self.controller.getActivityGroupCounter(ActivityCenterGroup.ContactRequests)
|
||||
|
||||
method getIdentityRequestsCount*(self: Module): int =
|
||||
return self.controller.getActivityGroupCounter(ActivityCenterGroup.IdentityVerification)
|
||||
|
||||
method getMembershipCount*(self: Module): int =
|
||||
return self.controller.getActivityGroupCounter(ActivityCenterGroup.Membership)
|
||||
|
|
|
@ -172,3 +172,47 @@ QtObject:
|
|||
read = getActivityCenterReadType
|
||||
write = setActivityCenterReadType
|
||||
notify = activityCenterReadTypeChanged
|
||||
|
||||
proc groupCountersChanged*(self: View) {.signal.}
|
||||
|
||||
proc getAdminCount*(self: View): int {.slot.} =
|
||||
return self.delegate.getAdminCount()
|
||||
|
||||
QtProperty[int] adminCount:
|
||||
read = getAdminCount
|
||||
notify = groupCountersChanged
|
||||
|
||||
proc getMentionsCount*(self: View): int {.slot.} =
|
||||
return self.delegate.getMentionsCount()
|
||||
|
||||
QtProperty[int] mentionsCount:
|
||||
read = getMentionsCount
|
||||
notify = groupCountersChanged
|
||||
|
||||
proc getRepliesCount*(self: View): int {.slot.} =
|
||||
return self.delegate.getRepliesCount()
|
||||
|
||||
QtProperty[int] repliesCount:
|
||||
read = getRepliesCount
|
||||
notify = groupCountersChanged
|
||||
|
||||
proc getContactRequestsCount*(self: View): int {.slot.} =
|
||||
return self.delegate.getContactRequestsCount()
|
||||
|
||||
QtProperty[int] contactRequestsCount:
|
||||
read = getContactRequestsCount
|
||||
notify = groupCountersChanged
|
||||
|
||||
proc getIdentityRequestsCount*(self: View): int {.slot.} =
|
||||
return self.delegate.getIdentityRequestsCount()
|
||||
|
||||
QtProperty[int] identityRequestsCount:
|
||||
read = getIdentityRequestsCount
|
||||
notify = groupCountersChanged
|
||||
|
||||
proc getMembershipCount*(self: View): int {.slot.} =
|
||||
return self.delegate.getMembershipCount()
|
||||
|
||||
QtProperty[int] membershipCount:
|
||||
read = getMembershipCount
|
||||
notify = groupCountersChanged
|
||||
|
|
|
@ -91,6 +91,7 @@ QtObject:
|
|||
SIGNAL_ACTIVITY_CENTER_NOTIFICATIONS_LOADED,
|
||||
ActivityCenterNotificationsArgs(activityCenterNotifications: filteredNotifications)
|
||||
)
|
||||
# NOTE: this signal must fire even we have no new notifications to show
|
||||
self.events.emit(SIGNAL_ACTIVITY_CENTER_NOTIFICATIONS_COUNT_MAY_HAVE_CHANGED, Args())
|
||||
|
||||
proc init*(self: Service) =
|
||||
|
@ -150,6 +151,16 @@ QtObject:
|
|||
self.cursor = activityCenterNotificationsTuple[0];
|
||||
result = activityCenterNotificationsTuple[1]
|
||||
|
||||
proc getActivityGroupCounter*(self: Service, group: ActivityCenterGroup): int =
|
||||
try:
|
||||
let response = backend.activityCenterNotificationsByGroupCount(group.int)
|
||||
|
||||
if response.result.kind != JNull:
|
||||
return response.result.getInt
|
||||
except Exception as e:
|
||||
error "Error getting activity center notifications group count", msg = e.msg
|
||||
|
||||
|
||||
proc getUnreadActivityCenterNotificationsCount*(self: Service): int =
|
||||
try:
|
||||
let response = backend.unreadActivityCenterNotificationsCount()
|
||||
|
|
|
@ -171,6 +171,9 @@ rpc(activityCenterNotificationsByGroup, "wakuext"):
|
|||
group: int
|
||||
readType: int
|
||||
|
||||
rpc(activityCenterNotificationsByGroupCount, "wakuext"):
|
||||
group: int
|
||||
|
||||
rpc(activityCenterTypesByGroup, "wakuext"):
|
||||
group: int
|
||||
|
||||
|
|
|
@ -18,14 +18,6 @@ import "../stores"
|
|||
Popup {
|
||||
id: root
|
||||
|
||||
// FIXME: counters from service
|
||||
property int adminCount: 1
|
||||
property int mentionsCount: 1
|
||||
property int repliesCount: 1
|
||||
property int contactRequestsCount: 1
|
||||
property int identityRequestsCount: 1
|
||||
property int membershipCount: 1
|
||||
|
||||
property ActivityCenterStore activityCenterStore
|
||||
property var store
|
||||
|
||||
|
@ -64,16 +56,16 @@ Popup {
|
|||
id: activityCenterTopBar
|
||||
width: parent.width
|
||||
unreadNotificationsCount: activityCenterStore.unreadNotificationsCount
|
||||
hasAdmin: root.adminCount > 0
|
||||
hasReplies: root.repliesCount > 0
|
||||
hasMentions: root.mentionsCount > 0
|
||||
hasContactRequests: root.contactRequestsCount > 0
|
||||
hasIdentityRequests: root.identityRequestsCount > 0
|
||||
hasMembership: root.membershipCount > 0
|
||||
hasAdmin: activityCenterStore.adminCount > 0
|
||||
hasReplies: activityCenterStore.repliesCount > 0
|
||||
hasMentions: activityCenterStore.mentionsCount > 0
|
||||
hasContactRequests: activityCenterStore.contactRequestsCount > 0
|
||||
hasIdentityRequests: activityCenterStore.identityRequestsCount > 0
|
||||
hasMembership: activityCenterStore.membershipCount > 0
|
||||
hideReadNotifications: activityCenterStore.activityCenterReadType === ActivityCenterStore.ActivityCenterReadType.Unread
|
||||
activeGroup: activityCenterStore.activeNotificationGroup
|
||||
onGroupTriggered: activityCenterStore.setActiveNotificationGroup(group)
|
||||
onMarkAllReadClicked: root.activityCenterStore.markAllActivityCenterNotificationsRead()
|
||||
onMarkAllReadClicked: activityCenterStore.markAllActivityCenterNotificationsRead()
|
||||
onShowHideReadNotifications: activityCenterStore.setActivityCenterReadType(hideReadNotifications ?
|
||||
ActivityCenterStore.ActivityCenterReadType.Unread :
|
||||
ActivityCenterStore.ActivityCenterReadType.All)
|
||||
|
|
|
@ -45,11 +45,19 @@ QtObject {
|
|||
|
||||
readonly property var activityCenterModuleInst: activityCenterModule
|
||||
readonly property var activityCenterNotifications: activityCenterModuleInst.activityNotificationsModel
|
||||
|
||||
readonly property int unreadNotificationsCount: activityCenterModuleInst.unreadActivityCenterNotificationsCount
|
||||
readonly property bool hasUnseenNotifications: activityCenterModuleInst.hasUnseenActivityCenterNotifications
|
||||
readonly property int activeNotificationGroup: activityCenterModuleInst.activeNotificationGroup
|
||||
readonly property int activityCenterReadType: activityCenterModuleInst.activityCenterReadType
|
||||
|
||||
readonly property int adminCount: activityCenterModuleInst.adminCount
|
||||
readonly property int mentionsCount: activityCenterModuleInst.mentionsCount
|
||||
readonly property int repliesCount: activityCenterModuleInst.repliesCount
|
||||
readonly property int contactRequestsCount: activityCenterModuleInst.contactRequestsCount
|
||||
readonly property int identityRequestsCount: activityCenterModuleInst.identityRequestsCount
|
||||
readonly property int membershipCount: activityCenterModuleInst.membershipCount
|
||||
|
||||
function markAllActivityCenterNotificationsRead() {
|
||||
root.activityCenterModuleInst.markAllActivityCenterNotificationsRead()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue