fix(act-center): fix unread count when accepting or dismissing notif
Fixes #2727
This commit is contained in:
parent
cd44b8a606
commit
e1c6cf224b
|
@ -129,6 +129,12 @@ QtObject:
|
||||||
let bottomRight = self.createIndex(self.activityCenterNotifications.len - 1, 0, nil)
|
let bottomRight = self.createIndex(self.activityCenterNotifications.len - 1, 0, nil)
|
||||||
self.dataChanged(topLeft, bottomRight, @[NotifRoles.Read.int])
|
self.dataChanged(topLeft, bottomRight, @[NotifRoles.Read.int])
|
||||||
|
|
||||||
|
proc reduceUnreadCount(self: ActivityNotificationList, numberNotifs: int) =
|
||||||
|
self.nbUnreadNotifications = self.nbUnreadNotifications - numberNotifs
|
||||||
|
if (self.nbUnreadNotifications < 0):
|
||||||
|
self.nbUnreadNotifications = 0
|
||||||
|
self.unreadCountChanged()
|
||||||
|
|
||||||
proc markActivityCenterNotificationsRead(self: ActivityNotificationList, idsJson: string): string {.slot.} =
|
proc markActivityCenterNotificationsRead(self: ActivityNotificationList, idsJson: string): string {.slot.} =
|
||||||
let ids = map(parseJson(idsJson).getElems(), proc(x:JsonNode):string = x.getStr())
|
let ids = map(parseJson(idsJson).getElems(), proc(x:JsonNode):string = x.getStr())
|
||||||
|
|
||||||
|
@ -136,10 +142,7 @@ QtObject:
|
||||||
if (error != ""):
|
if (error != ""):
|
||||||
return error
|
return error
|
||||||
|
|
||||||
self.nbUnreadNotifications = self.nbUnreadNotifications - ids.len
|
self.reduceUnreadCount(ids.len)
|
||||||
if (self.nbUnreadNotifications < 0):
|
|
||||||
self.nbUnreadNotifications = 0
|
|
||||||
self.unreadCountChanged()
|
|
||||||
|
|
||||||
var i = 0
|
var i = 0
|
||||||
for activityCenterNotification in self.activityCenterNotifications:
|
for activityCenterNotification in self.activityCenterNotifications:
|
||||||
|
@ -173,6 +176,8 @@ QtObject:
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
|
self.reduceUnreadCount(ids.len)
|
||||||
|
|
||||||
proc acceptActivityCenterNotifications(self: ActivityNotificationList, idsJson: string): string {.slot.} =
|
proc acceptActivityCenterNotifications(self: ActivityNotificationList, idsJson: string): string {.slot.} =
|
||||||
let ids = map(parseJson(idsJson).getElems(), proc(x:JsonNode):string = x.getStr())
|
let ids = map(parseJson(idsJson).getElems(), proc(x:JsonNode):string = x.getStr())
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 11c46edd8b25bb6b313b71378f1b3ac842ad1908
|
Subproject commit 491e2a84c4bc42a365b5e3c22fc9ca51e8719222
|
Loading…
Reference in New Issue