Timeline: force a build if decoration is SENT

This commit is contained in:
ganfra 2021-03-09 20:18:30 +01:00 committed by Benoit Marty
parent c9c4a203d1
commit 6977ee45da
1 changed files with 8 additions and 3 deletions

View File

@ -43,11 +43,13 @@ import im.vector.app.features.home.room.detail.timeline.helper.TimelineControlle
import im.vector.app.features.home.room.detail.timeline.helper.TimelineEventDiffUtilCallback
import im.vector.app.features.home.room.detail.timeline.helper.TimelineEventVisibilityStateChangedListener
import im.vector.app.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
import im.vector.app.features.home.room.detail.timeline.item.AbsMessageItem
import im.vector.app.features.home.room.detail.timeline.item.BasedMergedItem
import im.vector.app.features.home.room.detail.timeline.item.DaySeparatorItem
import im.vector.app.features.home.room.detail.timeline.item.DaySeparatorItem_
import im.vector.app.features.home.room.detail.timeline.item.MessageInformationData
import im.vector.app.features.home.room.detail.timeline.item.ReadReceiptData
import im.vector.app.features.home.room.detail.timeline.item.SendStateDecoration
import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever
import im.vector.app.features.media.ImageContentRenderer
import im.vector.app.features.media.VideoContentRenderer
@ -364,7 +366,9 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
requestModelBuild()
}
val daySeparatorItem = buildDaySeparatorItem(addDaySeparator, event.root.originServerTs)
return CacheItemData(event.localId, event.root.eventId, eventModel, mergedHeaderModel, daySeparatorItem)
// If we have a SENT decoration, we want to built again as it might have to be changed to NONE if more recent event has also SENT decoration
val forceTriggerBuild = eventModel is AbsMessageItem && eventModel.attributes.informationData.sendStateDecoration == SendStateDecoration.SENT
return CacheItemData(event.localId, event.root.eventId, eventModel, mergedHeaderModel, daySeparatorItem, forceTriggerBuild)
}
private fun buildDaySeparatorItem(addDaySeparator: Boolean, originServerTs: Long?): DaySeparatorItem? {
@ -427,11 +431,12 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
val eventId: String?,
val eventModel: EpoxyModel<*>? = null,
val mergedHeaderModel: BasedMergedItem<*>? = null,
val formattedDayModel: DaySeparatorItem? = null
val formattedDayModel: DaySeparatorItem? = null,
val forceTriggerBuild: Boolean = false
) {
fun shouldTriggerBuild(): Boolean {
// Since those items can change when we paginate, force a re-build
return mergedHeaderModel != null || formattedDayModel != null
return forceTriggerBuild || mergedHeaderModel != null || formattedDayModel != null
}
}
}