diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineHolder.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineHolder.kt index 4028ecddef..1b587cb87a 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineHolder.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineHolder.kt @@ -14,6 +14,8 @@ import im.vector.matrix.android.internal.database.query.where import im.vector.matrix.android.internal.session.events.interceptor.MessageEventInterceptor import io.realm.Sort +private const val PAGE_SIZE = 30 + class DefaultTimelineHolder(private val roomId: String, private val monarchy: Monarchy, private val boundaryCallback: TimelineBoundaryCallback @@ -22,6 +24,7 @@ class DefaultTimelineHolder(private val roomId: String, private val eventInterceptors = ArrayList() init { + boundaryCallback.limit = PAGE_SIZE eventInterceptors.add(MessageEventInterceptor(monarchy)) } @@ -37,6 +40,7 @@ class DefaultTimelineHolder(private val roomId: String, val domainSourceFactory = realmDataSourceFactory .map { it.asDomain() } .map { event -> + val enrichedEvent = EnrichedEvent(event) eventInterceptors .filter { @@ -49,7 +53,7 @@ class DefaultTimelineHolder(private val roomId: String, val pagedListConfig = PagedList.Config.Builder() .setEnablePlaceholders(false) - .setPageSize(10) + .setPageSize(PAGE_SIZE) .setPrefetchDistance(10) .build() diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt index 7a17527158..c8d76d7da2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt @@ -19,6 +19,8 @@ class TimelineBoundaryCallback(private val roomId: String, private val helper = PagingRequestHelper(ioExecutor) + var limit = 10 + override fun onZeroItemsLoaded() { // actually, it's not possible } @@ -30,7 +32,7 @@ class TimelineBoundaryCallback(private val roomId: String, return@doWithRealm } val chunkEntity = ChunkEntity.findAllIncludingEvents(realm, Collections.singletonList(itemAtEnd.root.eventId)).firstOrNull() - paginationRequest.execute(roomId, chunkEntity?.prevToken, PaginationDirection.BACKWARDS, callback = createCallback(it)) + paginationRequest.execute(roomId, chunkEntity?.prevToken, PaginationDirection.BACKWARDS, limit, callback = createCallback(it)) } } } @@ -42,7 +44,7 @@ class TimelineBoundaryCallback(private val roomId: String, return@doWithRealm } val chunkEntity = ChunkEntity.findAllIncludingEvents(realm, Collections.singletonList(itemAtFront.root.eventId)).firstOrNull() - paginationRequest.execute(roomId, chunkEntity?.nextToken, PaginationDirection.FORWARDS, callback = createCallback(it)) + paginationRequest.execute(roomId, chunkEntity?.nextToken, PaginationDirection.FORWARDS, limit, callback = createCallback(it)) } } }