Fix timeline rebuild on DM state change
Needs slightly different handling after
50a042683b
"Architecture: get rid of RoomSummariesHolder as it can lead to errors"
Change-Id: I1d34ca5058d93a73dc26c3b2fee7f8a296ec4880
This commit is contained in:
parent
25b11084f4
commit
f4d8f78ac7
|
@ -115,11 +115,6 @@ interface Timeline {
|
|||
*/
|
||||
fun getTimelineEventWithId(eventId: String?): TimelineEvent?
|
||||
|
||||
/**
|
||||
* Called when the DM flag of the room is changed
|
||||
*/
|
||||
fun onDmStateChanged()
|
||||
|
||||
interface Listener {
|
||||
/**
|
||||
* Call when the timeline has been updated through pagination or sync.
|
||||
|
@ -138,10 +133,6 @@ interface Timeline {
|
|||
*/
|
||||
fun onNewTimelineEvents(eventIds: List<String>)
|
||||
|
||||
/**
|
||||
* Called when the DM flag of the room is changed
|
||||
*/
|
||||
fun onDmStateChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -300,12 +300,6 @@ internal class DefaultTimeline(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onDmStateChanged() {
|
||||
listeners.forEach {
|
||||
it.onDmStateChanged()
|
||||
}
|
||||
}
|
||||
|
||||
override fun rebuildEvent(eventId: String, builder: (TimelineEvent) -> TimelineEvent?): Boolean {
|
||||
return tryOrNull {
|
||||
builtEventsIdMap[eventId]?.let { builtIndex ->
|
||||
|
|
|
@ -157,8 +157,6 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||
|
||||
private var prepareToEncrypt: Async<Unit> = Uninitialized
|
||||
|
||||
private var previousSummary: RoomSummary? = null
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: RoomDetailViewState): RoomDetailViewModel
|
||||
|
@ -1612,11 +1610,6 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||
room.getStateEvent(EventType.STATE_ROOM_TOMBSTONE)?.also {
|
||||
setState { copy(tombstoneEvent = it) }
|
||||
}
|
||||
val safePreviousSummary = previousSummary
|
||||
if (safePreviousSummary == null || safePreviousSummary.isDirect != summary.isDirect) {
|
||||
timeline.onDmStateChanged()
|
||||
}
|
||||
previousSummary = summary
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1657,8 +1650,4 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||
callManager.removeProtocolsCheckerListener(this)
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
override fun onDmStateChanged() {
|
||||
// No-op
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,6 +247,12 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
|
||||
fun update(viewState: RoomDetailViewState) = synchronized(modelCache) {
|
||||
val newPartialState = PartialState(viewState)
|
||||
if (partialState.roomSummary?.isDirect != newPartialState.roomSummary?.isDirect) {
|
||||
partialState = newPartialState
|
||||
invalidateFullTimeline()
|
||||
// This already called requestModelBuild
|
||||
return
|
||||
}
|
||||
if (partialState.highlightedEventId != newPartialState.highlightedEventId) {
|
||||
// Clear cache to force a refresh
|
||||
for (i in 0 until modelCache.size) {
|
||||
|
@ -313,7 +319,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
// no-op, already handled
|
||||
}
|
||||
|
||||
override fun onDmStateChanged() {
|
||||
private fun invalidateFullTimeline() {
|
||||
backgroundHandler.post {
|
||||
inSubmitList = true
|
||||
// Invalidate all timeline events to rebuild the whole Room/DM layout
|
||||
|
|
Loading…
Reference in New Issue