Fix timeline pagination when no displayable events
This commit is contained in:
parent
e8dbed1642
commit
3aabb17ea5
2 changed files with 6 additions and 3 deletions
|
@ -349,7 +349,7 @@ internal class DefaultTimeline(
|
||||||
|
|
||||||
updateState(Timeline.Direction.FORWARDS) {
|
updateState(Timeline.Direction.FORWARDS) {
|
||||||
it.copy(
|
it.copy(
|
||||||
hasMoreInCache = firstBuiltEvent == null || firstBuiltEvent.displayIndex < firstCacheEvent?.displayIndex ?: Int.MIN_VALUE,
|
hasMoreInCache = firstBuiltEvent != null && firstBuiltEvent.displayIndex < firstCacheEvent?.displayIndex ?: Int.MIN_VALUE,
|
||||||
hasReachedEnd = chunkEntity?.isLastForward ?: false
|
hasReachedEnd = chunkEntity?.isLastForward ?: false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -369,6 +369,9 @@ internal class DefaultTimeline(
|
||||||
private fun paginateInternal(startDisplayIndex: Int?,
|
private fun paginateInternal(startDisplayIndex: Int?,
|
||||||
direction: Timeline.Direction,
|
direction: Timeline.Direction,
|
||||||
count: Int): Boolean {
|
count: Int): Boolean {
|
||||||
|
if (count == 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
updateState(direction) { it.copy(requestedPaginationCount = count, isPaginating = true) }
|
updateState(direction) { it.copy(requestedPaginationCount = count, isPaginating = true) }
|
||||||
val builtCount = buildTimelineEvents(startDisplayIndex, direction, count.toLong())
|
val builtCount = buildTimelineEvents(startDisplayIndex, direction, count.toLong())
|
||||||
val shouldFetchMore = builtCount < count && !hasReachedEnd(direction)
|
val shouldFetchMore = builtCount < count && !hasReachedEnd(direction)
|
||||||
|
|
|
@ -241,12 +241,12 @@ internal class TokenChunkEventPersistor @Inject constructor(@SessionDatabase pri
|
||||||
chunksToDelete.add(it)
|
chunksToDelete.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val shouldUpdateSummary = chunksToDelete.isNotEmpty() && currentChunk.isLastForward && direction == PaginationDirection.FORWARDS
|
|
||||||
chunksToDelete.forEach {
|
chunksToDelete.forEach {
|
||||||
it.deleteOnCascade()
|
it.deleteOnCascade()
|
||||||
}
|
}
|
||||||
if (shouldUpdateSummary) {
|
|
||||||
val roomSummaryEntity = RoomSummaryEntity.getOrCreate(realm, roomId)
|
val roomSummaryEntity = RoomSummaryEntity.getOrCreate(realm, roomId)
|
||||||
|
val shouldUpdateSummary = roomSummaryEntity.latestPreviewableEvent == null || (chunksToDelete.isNotEmpty() && currentChunk.isLastForward && direction == PaginationDirection.FORWARDS)
|
||||||
|
if (shouldUpdateSummary) {
|
||||||
val latestPreviewableEvent = TimelineEventEntity.latestEvent(
|
val latestPreviewableEvent = TimelineEventEntity.latestEvent(
|
||||||
realm,
|
realm,
|
||||||
roomId,
|
roomId,
|
||||||
|
|
Loading…
Reference in a new issue