Timeline : re-add hasReachedEnd condition to get a better display

This commit is contained in:
ganfra 2019-01-11 15:17:15 +01:00
parent 2b66b4c4b7
commit 02254d5d31
1 changed files with 10 additions and 6 deletions

View File

@ -23,15 +23,19 @@ class TimelineEventController(private val roomId: String,
private var isLoadingForward: Boolean = false private var isLoadingForward: Boolean = false
private var isLoadingBackward: Boolean = false private var isLoadingBackward: Boolean = false
private var hasReachedEnd: Boolean = false
var callback: Callback? = null var callback: Callback? = null
fun update(timelineData: TimelineData?) { fun update(timelineData: TimelineData?) {
isLoadingForward = timelineData?.isLoadingForward ?: false timelineData?.let {
isLoadingBackward = timelineData?.isLoadingBackward ?: false isLoadingForward = it.isLoadingForward
submitList(timelineData?.events) isLoadingBackward = it.isLoadingBackward
hasReachedEnd = it.events.lastOrNull()?.root?.type == EventType.STATE_ROOM_CREATE
submitList(it.events)
requestModelBuild() requestModelBuild()
} }
}
override fun buildItemModels(currentPosition: Int, items: List<EnrichedEvent?>): List<EpoxyModel<*>> { override fun buildItemModels(currentPosition: Int, items: List<EnrichedEvent?>): List<EpoxyModel<*>> {
@ -72,7 +76,7 @@ class TimelineEventController(private val roomId: String,
LoadingItemModel_() LoadingItemModel_()
.id(roomId + "backward_loading_item") .id(roomId + "backward_loading_item")
.addIf(isLoadingBackward, this) .addIf(!hasReachedEnd, this)
} }