Reuse previously build room summaries for diffs that contain invalidations

This commit is contained in:
Stefan Ceriu
2023-06-26 12:27:14 +03:00
committed by Stefan Ceriu
parent 54a7e7acf0
commit 4c45d8722c

View File

@@ -177,7 +177,18 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
case .filled(let roomId):
return buildRoomSummaryForIdentifier(roomId, invalidated: false)
case .invalidated(let roomId):
return buildRoomSummaryForIdentifier(roomId, invalidated: true)
guard let cachedRoom = rooms.first(where: { $0.id == roomId }) else {
return buildRoomSummaryForIdentifier(roomId, invalidated: true)
}
switch cachedRoom {
case .empty:
return .empty
case .filled(let details):
return .invalidated(details: details)
case .invalidated:
return cachedRoom
}
}
}