mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Remove unused RoomSummary cache (#3647)
This commit is contained in:
committed by
GitHub
parent
9c7f2b992a
commit
22f79f2726
+7
-14
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user