mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user