mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Timeline: dispatch update on a background thread
This commit is contained in:
parent
3bdf264a53
commit
c66d6aab5c
1 changed files with 14 additions and 12 deletions
|
@ -244,20 +244,22 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
||||||
interceptorHelper.intercept(models, partialState.unreadState, timeline, callback)
|
interceptorHelper.intercept(models, partialState.unreadState, timeline, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(viewState: RoomDetailViewState) = synchronized(modelCache) {
|
fun update(viewState: RoomDetailViewState) = backgroundHandler.post {
|
||||||
val newPartialState = PartialState(viewState)
|
synchronized(modelCache) {
|
||||||
if (partialState.highlightedEventId != newPartialState.highlightedEventId) {
|
val newPartialState = PartialState(viewState)
|
||||||
// Clear cache to force a refresh
|
if (partialState.highlightedEventId != newPartialState.highlightedEventId) {
|
||||||
for (i in 0 until modelCache.size) {
|
// Clear cache to force a refresh
|
||||||
if (modelCache[i]?.eventId == viewState.highlightedEventId ||
|
for (i in 0 until modelCache.size) {
|
||||||
modelCache[i]?.eventId == partialState.highlightedEventId) {
|
if (modelCache[i]?.eventId == viewState.highlightedEventId ||
|
||||||
modelCache[i] = null
|
modelCache[i]?.eventId == partialState.highlightedEventId) {
|
||||||
|
modelCache[i] = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (newPartialState != partialState) {
|
||||||
if (newPartialState != partialState) {
|
partialState = newPartialState
|
||||||
partialState = newPartialState
|
requestModelBuild()
|
||||||
requestModelBuild()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue