fix(activity_center): Remove notifications from activity center
Fixes: #9751
This commit is contained in:
parent
ee56e79090
commit
0b6ff5ae2f
|
@ -76,6 +76,11 @@ proc init*(self: Controller) =
|
|||
self.delegate.hasUnseenActivityCenterNotificationsChanged()
|
||||
self.updateActivityGroupCounters()
|
||||
|
||||
self.events.on(activity_center_service.SIGNAL_ACTIVITY_CENTER_NOTIFICATIONS_REMOVED) do(e: Args):
|
||||
var evArgs = RemoveActivityCenterNotificationsArgs(e)
|
||||
if (evArgs.notificationIds.len > 0):
|
||||
self.delegate.removeActivityCenterNotifications(evArgs.notificationIds)
|
||||
|
||||
proc hasMoreToShow*(self: Controller): bool =
|
||||
return self.activityCenterService.hasMoreToShow()
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ method markActivityCenterNotificationReadDone*(self: AccessInterface, notificati
|
|||
method markActivityCenterNotificationUnreadDone*(self: AccessInterface, notificationIds: seq[string]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method removeActivityCenterNotifications*(self: AccessInterface, notificationIds: seq[string]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method acceptActivityCenterNotificationsDone*(self: AccessInterface, notificationIds: seq[string]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -239,6 +239,9 @@ method markActivityCenterNotificationUnreadDone*(self: Module, notificationIds:
|
|||
for notificationId in notificationIds:
|
||||
self.view.markActivityCenterNotificationUnreadDone(notificationId)
|
||||
|
||||
method removeActivityCenterNotifications*(self: Module, notificationIds: seq[string]) =
|
||||
self.view.removeActivityCenterNotifications(notificationIds)
|
||||
|
||||
method acceptActivityCenterNotificationsDone*(self: Module, notificationIds: seq[string]) =
|
||||
self.view.acceptActivityCenterNotificationsDone(notificationIds)
|
||||
|
||||
|
|
|
@ -86,6 +86,9 @@ QtObject:
|
|||
proc markActivityCenterNotificationUnreadDone*(self: View, notificationId: string) =
|
||||
self.model.markActivityCenterNotificationUnread(notificationId)
|
||||
|
||||
proc removeActivityCenterNotifications*(self: View, notificationIds: seq[string]) =
|
||||
self.model.removeNotifications(notificationIds)
|
||||
|
||||
proc markAllChatMentionsAsRead*(self: View, communityId: string, chatId: string) =
|
||||
let notifsIds = self.model.getUnreadNotificationsForChat(chatId)
|
||||
for notifId in notifsIds:
|
||||
|
|
|
@ -56,6 +56,7 @@ type ActivityCenterNotificationDto* = ref object of RootObj
|
|||
timestamp*: int64
|
||||
read*: bool
|
||||
dismissed*: bool
|
||||
deleted*: bool
|
||||
accepted*: bool
|
||||
|
||||
proc `$`*(self: ActivityCenterNotificationDto): string =
|
||||
|
@ -70,6 +71,7 @@ proc `$`*(self: ActivityCenterNotificationDto): string =
|
|||
timestamp: {self.timestamp},
|
||||
read: {$self.read},
|
||||
dismissed: {$self.dismissed},
|
||||
deleted: {$self.deleted},
|
||||
accepted: {$self.accepted},
|
||||
message: {self.message}
|
||||
replyMessage: {self.replyMessage}
|
||||
|
@ -107,6 +109,7 @@ proc toActivityCenterNotificationDto*(jsonObj: JsonNode): ActivityCenterNotifica
|
|||
discard jsonObj.getProp("timestamp", result.timestamp)
|
||||
discard jsonObj.getProp("read", result.read)
|
||||
discard jsonObj.getProp("dismissed", result.dismissed)
|
||||
discard jsonObj.getProp("deleted", result.deleted)
|
||||
discard jsonObj.getProp("accepted", result.accepted)
|
||||
|
||||
if jsonObj.contains("message") and jsonObj{"message"}.kind != JNull:
|
||||
|
|
|
@ -25,6 +25,9 @@ type
|
|||
MarkAsAcceptedNotificationProperties* = ref object of Args
|
||||
notificationIds*: seq[string]
|
||||
|
||||
RemoveActivityCenterNotificationsArgs* = ref object of Args
|
||||
notificationIds*: seq[string]
|
||||
|
||||
MarkAsDismissedNotificationProperties* = ref object of Args
|
||||
notificationIds*: seq[string]
|
||||
|
||||
|
@ -48,6 +51,7 @@ const SIGNAL_MARK_NOTIFICATIONS_AS_READ* = "markNotificationsAsRead"
|
|||
const SIGNAL_MARK_NOTIFICATIONS_AS_UNREAD* = "markNotificationsAsUnread"
|
||||
const SIGNAL_MARK_NOTIFICATIONS_AS_ACCEPTED* = "markNotificationsAsAccepted"
|
||||
const SIGNAL_MARK_NOTIFICATIONS_AS_DISMISSED* = "markNotificationsAsDismissed"
|
||||
const SIGNAL_ACTIVITY_CENTER_NOTIFICATIONS_REMOVED* = "activityCenterNotificationsRemoved"
|
||||
|
||||
const DEFAULT_LIMIT = 20
|
||||
|
||||
|
@ -93,12 +97,24 @@ QtObject:
|
|||
let filteredNotifications = filter(activityCenterNotifications, proc(notification: ActivityCenterNotificationDto): bool =
|
||||
return (self.readType == ActivityCenterReadType.All or not notification.read) and groupTypes.contains(notification.notificationType.int)
|
||||
)
|
||||
let removedNotifications = filter(activityCenterNotifications, proc(notification: ActivityCenterNotificationDto): bool =
|
||||
return notification.deleted
|
||||
)
|
||||
|
||||
if (filteredNotifications.len > 0):
|
||||
self.events.emit(
|
||||
SIGNAL_ACTIVITY_CENTER_NOTIFICATIONS_LOADED,
|
||||
ActivityCenterNotificationsArgs(activityCenterNotifications: filteredNotifications)
|
||||
)
|
||||
|
||||
if (removedNotifications.len > 0):
|
||||
var notificationIds: seq[string]
|
||||
for notification in removedNotifications:
|
||||
notificationIds.add(notification.id)
|
||||
|
||||
self.events.emit(SIGNAL_ACTIVITY_CENTER_NOTIFICATIONS_REMOVED, RemoveActivityCenterNotificationsArgs(
|
||||
notificationIds: notificationIds
|
||||
))
|
||||
# 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())
|
||||
|
||||
|
@ -106,7 +122,8 @@ QtObject:
|
|||
self.asyncActivityNotificationLoad()
|
||||
self.events.on(SignalType.Message.event) do(e: Args):
|
||||
let receivedData = MessageSignal(e)
|
||||
self.handleNewNotificationsLoaded(receivedData.activityCenterNotifications)
|
||||
if (receivedData.activityCenterNotifications.len > 0):
|
||||
self.handleNewNotificationsLoaded(receivedData.activityCenterNotifications)
|
||||
|
||||
proc parseActivityCenterResponse*(self: Service, response: RpcResponse[JsonNode]) =
|
||||
var activityCenterNotifications: seq[ActivityCenterNotificationDto] = @[]
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0eef19f80e1980f737894b7e258e2853c023a35a
|
||||
Subproject commit 106e3e3b137783f9af60e28efc1e4fafec363f61
|
Loading…
Reference in New Issue