From 46cc7a6849032e502a57d32006b42ce8d574ab58 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sat, 4 Feb 2023 09:02:16 +0100 Subject: [PATCH] Fix a crash in notification stream --- .../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 6c33a8d1..1d6edb8e 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift @@ -118,7 +118,8 @@ class NotificationsViewModel: ObservableObject { !consolidatedNotifications.flatMap(\.notificationIds).contains(event.notification.id), selectedType == nil || selectedType?.rawValue == event.notification.type { - if event.notification.isConsolidable(selectedType: selectedType) { + if event.notification.isConsolidable(selectedType: selectedType), + !consolidatedNotifications.isEmpty { // If the notification type can be consolidated, try to consolidate with the latest row let latestConsolidatedNotification = consolidatedNotifications.removeFirst() consolidatedNotifications.insert(