Don't add duplicate notifications

This commit is contained in:
Thomas Ricouard 2022-12-30 15:17:45 +01:00
parent 07bfa47d49
commit 9cf7066663

View file

@ -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)
}