Focus events on the live timeline when it has already loaded them

Opening a room on an event always built a detached timeline, even when the
live timeline already contained that event, e.g. when tapping the notification
for the newest message in a room.

The timeline controller now stays on the live timeline in that case, scrolling
to and highlighting the event, and only builds a detached timeline when the
event isn't loaded.
This commit is contained in:
Stefan Ceriu
2026-10-02 15:22:56 +03:00
parent 52b411e954
commit 9f141585a2
3 changed files with 87 additions and 1 deletions
@@ -63,7 +63,8 @@ class TimelineController: TimelineControllerProtocol {
activeTimeline = timelineProxy
activeTimelineItemProvider = liveTimelineItemProvider
guard let initialFocussedEventID else {
// No need for a detached timeline when the live one has already loaded the event.
guard let initialFocussedEventID, !liveTimelineItemProvider.containsEvent(initialFocussedEventID) else {
configureActiveTimelineItemProvider()
return
}
@@ -765,3 +766,12 @@ private nonisolated extension TimelineItemProxy {
return false
}
}
private extension TimelineItemProviderProtocol {
func containsEvent(_ eventID: String) -> Bool {
itemProxies.contains { item in
guard case let .event(eventItem) = item else { return false }
return eventItem.id.eventID == eventID
}
}
}