From 4f145e365e721830e466128937d0dca7c6e1948d Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 8 Sep 2021 15:33:40 +0200 Subject: [PATCH] Timeline: small on fixes on new implementation --- .../internal/session/room/timeline/DefaultTimeline.kt | 1 - .../room/detail/timeline/TimelineEventController.kt | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt index 141d33ad0e..b102ab9fd7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt @@ -109,7 +109,6 @@ class DefaultTimeline internal constructor(private val roomId: String, ensureReadReceiptAreLoaded(realm) backgroundRealm.set(realm) openAround(initialEventId) - strategy.onStart() } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/TimelineEventController.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/TimelineEventController.kt index e272ee86c9..923404ac5e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/TimelineEventController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/TimelineEventController.kt @@ -58,6 +58,7 @@ import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever import im.vector.app.features.media.ImageContentRenderer import im.vector.app.features.media.VideoContentRenderer import im.vector.app.features.settings.VectorPreferences +import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.toModel @@ -355,7 +356,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec timelineEventVisibilityHelper.shouldShowEvent(it, partialState.highlightedEventId) } // Should be build if not cached or if model should be refreshed - if (modelCache[position] == null || modelCache[position]?.isCacheable == false) { + if (modelCache[position] == null || modelCache[position]?.isCacheable(partialState).orFalse()) { val timelineEventsGroup = timelineEventsGroups.getOrNull(event) val params = TimelineItemFactoryParams( event = event, @@ -537,6 +538,10 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec val eventModel: EpoxyModel<*>? = null, val mergedHeaderModel: BasedMergedItem<*>? = null, val formattedDayModel: DaySeparatorItem? = null, - val isCacheable: Boolean = true - ) + private val isCacheable: Boolean = true + ) { + fun isCacheable(partialState: PartialState): Boolean { + return isCacheable || partialState.highlightedEventId == eventId + } + } }