From b92cc524b6faba18ce64a4e0d8d9e1fb64a54141 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 27 Jun 2019 16:46:22 +0200 Subject: [PATCH] Fix / Day separator flickering in timeline Sending events were not filtered, so sending events like reactions would make the day separator appear --- .../session/room/timeline/DefaultTimeline.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt index 6743d1cb0b..4900ccbbd7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt @@ -125,7 +125,7 @@ internal class DefaultTimeline( } var hasChanged = false - changeSet.changes.forEach {index -> + changeSet.changes.forEach { index -> val eventEntity = results[index] eventEntity?.eventId?.let { eventId -> builtEventsIdMap[eventId]?.let { builtIndex -> @@ -289,10 +289,12 @@ internal class DefaultTimeline( private fun buildSendingEvents(): List { val sendingEvents = ArrayList() if (hasReachedEnd(Timeline.Direction.FORWARDS)) { - roomEntity?.sendingTimelineEvents?.forEach { - val timelineEvent = timelineEventFactory.create(it) - sendingEvents.add(timelineEvent) - } + roomEntity?.sendingTimelineEvents + ?.filter { allowedTypes?.contains(it.type) ?: false } + ?.forEach { + val timelineEvent = timelineEventFactory.create(it) + sendingEvents.add(timelineEvent) + } } return sendingEvents } @@ -303,14 +305,14 @@ internal class DefaultTimeline( private fun getPaginationState(direction: Timeline.Direction): PaginationState { return when (direction) { - Timeline.Direction.FORWARDS -> forwardsPaginationState.get() + Timeline.Direction.FORWARDS -> forwardsPaginationState.get() Timeline.Direction.BACKWARDS -> backwardsPaginationState.get() } } private fun updatePaginationState(direction: Timeline.Direction, update: (PaginationState) -> PaginationState) { val stateReference = when (direction) { - Timeline.Direction.FORWARDS -> forwardsPaginationState + Timeline.Direction.FORWARDS -> forwardsPaginationState Timeline.Direction.BACKWARDS -> backwardsPaginationState } val currentValue = stateReference.get()