diff --git a/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift b/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift index de49a5c92..e61b5b7b6 100644 --- a/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift +++ b/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift @@ -133,35 +133,41 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { MXLog.verbose("\(name): Received \(diffs.count) diffs, current room list \(rooms.compactMap { $0.id ?? "Empty" })") + var updatedItems = rooms for diff in diffs { - // Special case resets in order to prevent large updates from blocking the UI - // Render the first resetDiffChunkingThreshhold as a reset and then append the rest to give the UI time to update let resetDiffChunkingThreshhold = 50 if case .reset(let values) = diff, values.count > resetDiffChunkingThreshhold { - processDiff(RoomListEntriesUpdate.reset(values: Array(values[.. [RoomSummary] { + guard let collectionDiff = buildDiff(from: diff, on: currentItems) else { MXLog.error("\(name): Failed building CollectionDifference from \(diff)") - return + return currentItems } - guard let updatedItems = rooms.applying(collectionDiff) else { + guard let updatedItems = currentItems.applying(collectionDiff) else { MXLog.error("\(name): Failed applying diff: \(collectionDiff)") - return + return currentItems } - rooms = updatedItems + return updatedItems } private func fetchRoomInfo(roomListItem: RoomListItemProtocol) -> RoomInfo? {