From 9cf7066663e873822cf1434752894d6172ba10d7 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Fri, 30 Dec 2022 15:17:45 +0100 Subject: [PATCH] Don't add duplicate notifications --- .../Sources/Notifications/NotificationsViewModel.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift b/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift index 1ae175f2..e007ae4f 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift @@ -90,7 +90,8 @@ class NotificationsViewModel: ObservableObject { } func handleEvent(event: any StreamEvent) { - if let event = event as? StreamEventNotification { + if let event = event as? StreamEventNotification, + !notifications.contains(where: { $0.id == event.notification.id }) { notifications.insert(event.notification, at: 0) state = .display(notifications: notifications, nextPageState: .hasNextPage) }