mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-16 17:55:13 +00:00
Correctly updated grouped notifications
This commit is contained in:
parent
71027e2cc3
commit
9af485b2be
1 changed files with 15 additions and 7 deletions
|
@ -198,13 +198,21 @@ import SwiftUI
|
||||||
if event.notification.isConsolidable(selectedType: selectedType),
|
if event.notification.isConsolidable(selectedType: selectedType),
|
||||||
!consolidatedNotifications.isEmpty
|
!consolidatedNotifications.isEmpty
|
||||||
{
|
{
|
||||||
// If the notification type can be consolidated, try to consolidate with the latest row
|
if let index = consolidatedNotifications.firstIndex(where: { $0.type == event.notification.supportedType && $0.status?.id == event.notification.status?.id }) {
|
||||||
let latestConsolidatedNotification = consolidatedNotifications.removeFirst()
|
let latestConsolidatedNotification = consolidatedNotifications.remove(at: index)
|
||||||
await consolidatedNotifications.insert(
|
await consolidatedNotifications.insert(
|
||||||
contentsOf: ([event.notification] + latestConsolidatedNotification.notifications)
|
contentsOf: ([event.notification] + latestConsolidatedNotification.notifications)
|
||||||
.consolidated(selectedType: selectedType),
|
.consolidated(selectedType: selectedType),
|
||||||
at: 0
|
at: 0
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
let latestConsolidatedNotification = consolidatedNotifications.removeFirst()
|
||||||
|
await consolidatedNotifications.insert(
|
||||||
|
contentsOf: ([event.notification] + latestConsolidatedNotification.notifications)
|
||||||
|
.consolidated(selectedType: selectedType),
|
||||||
|
at: 0
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, just insert the new notification
|
// Otherwise, just insert the new notification
|
||||||
await consolidatedNotifications.insert(
|
await consolidatedNotifications.insert(
|
||||||
|
|
Loading…
Reference in a new issue