@@ -216,10 +216,11 @@ private extension PushNotificationViewModel {
216216 state. nextCursor = nil
217217 return [ . fetchNotifications( state. query, cursor: nil ) ]
218218 case . loadNextPage:
219- guard state. hasMore, !state. isLoading else { return [ ] }
219+ guard state. hasMore, !state. isLoading, state . pendingTask == nil else { return [ ] }
220220 return [ . fetchNotifications( state. query, cursor: state. nextCursor) ]
221221 case . confirmDelete:
222- guard let ( item, _ ) = state. pendingTask else { return [ ] }
222+ guard let ( item, _) = state. pendingTask else { return [ ] }
223+ state. pendingTask = nil
223224 return [ . delete( item) ]
224225 case . setToast( let isPresented, let type) :
225226 setToast ( & state, isPresented: isPresented, for: type)
@@ -241,7 +242,13 @@ private extension PushNotificationViewModel {
241242 state. notifications = [ ]
242243 state. nextCursor = nil
243244 case . appendNotifications( let notifications, let nextCursor) :
244- state. notifications. append ( contentsOf: notifications)
245+ let filteredNotifications : [ PushNotification ]
246+ if let ( pendingItem, _) = state. pendingTask {
247+ filteredNotifications = notifications. filter { $0. id != pendingItem. id }
248+ } else {
249+ filteredNotifications = notifications
250+ }
251+ state. notifications. append ( contentsOf: filteredNotifications)
245252 state. nextCursor = nextCursor
246253 default :
247254 break
0 commit comments