mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-23 22:39:02 +03:00
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
4 changed files with 7 additions and 27 deletions
matrix-sdk-android/src/main/java/org/matrix/android/sdk
vector/src/main/java/im/vector/app/features/home/room/detail
|
@ -115,11 +115,6 @@ interface Timeline {
|
||||||
*/
|
*/
|
||||||
fun getTimelineEventWithId(eventId: String?): TimelineEvent?
|
fun getTimelineEventWithId(eventId: String?): TimelineEvent?
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the DM flag of the room is changed
|
|
||||||
*/
|
|
||||||
fun onDmStateChanged()
|
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
/**
|
/**
|
||||||
* Call when the timeline has been updated through pagination or sync.
|
* Call when the timeline has been updated through pagination or sync.
|
||||||
|
@ -138,10 +133,6 @@ interface Timeline {
|
||||||
*/
|
*/
|
||||||
fun onNewTimelineEvents(eventIds: List<String>)
|
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 {
|
override fun rebuildEvent(eventId: String, builder: (TimelineEvent) -> TimelineEvent?): Boolean {
|
||||||
return tryOrNull {
|
return tryOrNull {
|
||||||
builtEventsIdMap[eventId]?.let { builtIndex ->
|
builtEventsIdMap[eventId]?.let { builtIndex ->
|
||||||
|
|
|
@ -157,8 +157,6 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
private var prepareToEncrypt: Async<Unit> = Uninitialized
|
private var prepareToEncrypt: Async<Unit> = Uninitialized
|
||||||
|
|
||||||
private var previousSummary: RoomSummary? = null
|
|
||||||
|
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
fun create(initialState: RoomDetailViewState): RoomDetailViewModel
|
fun create(initialState: RoomDetailViewState): RoomDetailViewModel
|
||||||
|
@ -1612,11 +1610,6 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
room.getStateEvent(EventType.STATE_ROOM_TOMBSTONE)?.also {
|
room.getStateEvent(EventType.STATE_ROOM_TOMBSTONE)?.also {
|
||||||
setState { copy(tombstoneEvent = it) }
|
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)
|
callManager.removeProtocolsCheckerListener(this)
|
||||||
super.onCleared()
|
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) {
|
fun update(viewState: RoomDetailViewState) = synchronized(modelCache) {
|
||||||
val newPartialState = PartialState(viewState)
|
val newPartialState = PartialState(viewState)
|
||||||
|
if (partialState.roomSummary?.isDirect != newPartialState.roomSummary?.isDirect) {
|
||||||
|
partialState = newPartialState
|
||||||
|
invalidateFullTimeline()
|
||||||
|
// This already called requestModelBuild
|
||||||
|
return
|
||||||
|
}
|
||||||
if (partialState.highlightedEventId != newPartialState.highlightedEventId) {
|
if (partialState.highlightedEventId != newPartialState.highlightedEventId) {
|
||||||
// Clear cache to force a refresh
|
// Clear cache to force a refresh
|
||||||
for (i in 0 until modelCache.size) {
|
for (i in 0 until modelCache.size) {
|
||||||
|
@ -313,7 +319,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
||||||
// no-op, already handled
|
// no-op, already handled
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDmStateChanged() {
|
private fun invalidateFullTimeline() {
|
||||||
backgroundHandler.post {
|
backgroundHandler.post {
|
||||||
inSubmitList = true
|
inSubmitList = true
|
||||||
// Invalidate all timeline events to rebuild the whole Room/DM layout
|
// Invalidate all timeline events to rebuild the whole Room/DM layout
|
||||||
|
|
Loading…
Add table
Reference in a new issue