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,14 +23,18 @@ 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
requestModelBuild() hasReachedEnd = it.events.lastOrNull()?.root?.type == EventType.STATE_ROOM_CREATE
submitList(it.events)
requestModelBuild()
}
} }




@ -48,7 +52,7 @@ class TimelineEventController(private val roomId: String,


val item = when (event.root.type) { val item = when (event.root.type) {
EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, addDaySeparator, date, callback) EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, addDaySeparator, date, callback)
else -> textItemFactory.create(event) else -> textItemFactory.create(event)
} }
item?.also { item?.also {
it.id(event.localId) it.id(event.localId)
@ -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)
} }