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