Remove unused RoomSummary cache (#3647)
This commit is contained in:
parent
354349df19
commit
9db6e97d31
1 changed files with 7 additions and 14 deletions
|
|
@ -25,7 +25,6 @@ class RoomSummaryListProcessor(
|
||||||
private val coroutineContext: CoroutineContext,
|
private val coroutineContext: CoroutineContext,
|
||||||
private val roomSummaryDetailsFactory: RoomSummaryFactory = RoomSummaryFactory(),
|
private val roomSummaryDetailsFactory: RoomSummaryFactory = RoomSummaryFactory(),
|
||||||
) {
|
) {
|
||||||
private val roomSummariesByIdentifier = HashMap<String, RoomSummary>()
|
|
||||||
private val mutex = Mutex()
|
private val mutex = Mutex()
|
||||||
|
|
||||||
suspend fun postUpdate(updates: List<RoomListEntriesUpdate>) {
|
suspend fun postUpdate(updates: List<RoomListEntriesUpdate>) {
|
||||||
|
|
@ -40,7 +39,7 @@ class RoomSummaryListProcessor(
|
||||||
suspend fun rebuildRoomSummaries() {
|
suspend fun rebuildRoomSummaries() {
|
||||||
updateRoomSummaries {
|
updateRoomSummaries {
|
||||||
forEachIndexed { i, summary ->
|
forEachIndexed { i, summary ->
|
||||||
val result = buildAndCacheRoomSummaryForIdentifier(summary.roomId.value)
|
val result = buildRoomSummaryForIdentifier(summary.roomId.value)
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
this[i] = result
|
this[i] = result
|
||||||
}
|
}
|
||||||
|
|
@ -97,23 +96,17 @@ class RoomSummaryListProcessor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun buildSummaryForRoomListEntry(entry: RoomListItem): RoomSummary {
|
private suspend fun buildSummaryForRoomListEntry(entry: RoomListItem): RoomSummary {
|
||||||
return buildAndCacheRoomSummaryForRoomListItem(entry)
|
return buildRoomSummaryForRoomListItem(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun buildAndCacheRoomSummaryForIdentifier(identifier: String): RoomSummary? {
|
private suspend fun buildRoomSummaryForIdentifier(identifier: String): RoomSummary? {
|
||||||
val builtRoomSummary = roomListService.roomOrNull(identifier)?.use { roomListItem ->
|
return roomListService.roomOrNull(identifier)?.use { roomListItem ->
|
||||||
buildAndCacheRoomSummaryForRoomListItem(roomListItem)
|
buildRoomSummaryForRoomListItem(roomListItem)
|
||||||
}
|
}
|
||||||
if (builtRoomSummary == null) {
|
|
||||||
roomSummariesByIdentifier.remove(identifier)
|
|
||||||
}
|
|
||||||
return builtRoomSummary
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun buildAndCacheRoomSummaryForRoomListItem(roomListItem: RoomListItem): RoomSummary {
|
private suspend fun buildRoomSummaryForRoomListItem(roomListItem: RoomListItem): RoomSummary {
|
||||||
val builtRoomSummary = roomSummaryDetailsFactory.create(roomListItem = roomListItem)
|
return roomSummaryDetailsFactory.create(roomListItem = roomListItem)
|
||||||
roomSummariesByIdentifier[builtRoomSummary.roomId.value] = builtRoomSummary
|
|
||||||
return builtRoomSummary
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun updateRoomSummaries(block: suspend MutableList<RoomSummary>.() -> Unit) = withContext(coroutineContext) {
|
private suspend fun updateRoomSummaries(block: suspend MutableList<RoomSummary>.() -> Unit) = withContext(coroutineContext) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue