forked from GitHub-Mirror/riotX-android
Fix timeline forward loader showing when sending events
This commit is contained in:
parent
585f0ba4b7
commit
7f09e64d63
@ -278,30 +278,32 @@ internal class DefaultTimeline(
|
|||||||
// Private methods *****************************************************************************
|
// Private methods *****************************************************************************
|
||||||
|
|
||||||
private fun hasMoreInCache(direction: Timeline.Direction): Boolean {
|
private fun hasMoreInCache(direction: Timeline.Direction): Boolean {
|
||||||
val localRealm = Realm.getInstance(realmConfiguration)
|
return Realm.getInstance(realmConfiguration).use { localRealm ->
|
||||||
val timelineEventEntity = buildEventQuery(localRealm).findFirst(direction) ?: return false
|
val timelineEventEntity = buildEventQuery(localRealm).findFirst(direction)
|
||||||
val hasMoreInCache = if (direction == Timeline.Direction.FORWARDS) {
|
?: return false
|
||||||
val firstEvent = builtEvents.firstOrNull() ?: return true
|
if (direction == Timeline.Direction.FORWARDS) {
|
||||||
firstEvent.displayIndex < timelineEventEntity.root!!.displayIndex
|
if (findCurrentChunk(localRealm)?.isLastForward == true) {
|
||||||
} else {
|
return false
|
||||||
val lastEvent = builtEvents.lastOrNull() ?: return true
|
}
|
||||||
lastEvent.displayIndex > timelineEventEntity.root!!.displayIndex
|
val firstEvent = builtEvents.firstOrNull() ?: return true
|
||||||
|
firstEvent.displayIndex < timelineEventEntity.root!!.displayIndex
|
||||||
|
} else {
|
||||||
|
val lastEvent = builtEvents.lastOrNull() ?: return true
|
||||||
|
lastEvent.displayIndex > timelineEventEntity.root!!.displayIndex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
localRealm.close()
|
|
||||||
return hasMoreInCache
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasReachedEnd(direction: Timeline.Direction): Boolean {
|
private fun hasReachedEnd(direction: Timeline.Direction): Boolean {
|
||||||
val localRealm = Realm.getInstance(realmConfiguration)
|
return Realm.getInstance(realmConfiguration).use { localRealm ->
|
||||||
val currentChunk = findCurrentChunk(localRealm) ?: return false
|
val currentChunk = findCurrentChunk(localRealm) ?: return false
|
||||||
val hasReachedEnd = if (direction == Timeline.Direction.FORWARDS) {
|
if (direction == Timeline.Direction.FORWARDS) {
|
||||||
currentChunk.isLastForward
|
currentChunk.isLastForward
|
||||||
} else {
|
} else {
|
||||||
val eventEntity = buildEventQuery(localRealm).findFirst(direction)
|
val eventEntity = buildEventQuery(localRealm).findFirst(direction)
|
||||||
currentChunk.isLastBackward || eventEntity?.root?.type == EventType.STATE_ROOM_CREATE
|
currentChunk.isLastBackward || eventEntity?.root?.type == EventType.STATE_ROOM_CREATE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
localRealm.close()
|
|
||||||
return hasReachedEnd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user