diff --git a/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift b/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift index 37563c65..21769fc2 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift @@ -221,6 +221,7 @@ extension TimelineViewModel: StatusesFetcher { // Fetch pages from the top most status of the tomeline. private func fetchNewPagesFrom(latestStatus: Status, client _: Client) async throws { canStreamEvents = false + let initialTimeline = timeline var newStatuses: [Status] = await fetchNewPages(minId: latestStatus.id, maxPages: 10) // Dedup statuses, a status with the same id could have been streamed in. @@ -247,6 +248,12 @@ extension TimelineViewModel: StatusesFetcher { canStreamEvents = true return } + + // As this is a long runnign task we need to ensure that the user didn't changed the timeline filter. + guard initialTimeline == timeline else { + canStreamEvents = true + return + } // Keep track of the top most status, so we can scroll back to it after view update. let topStatusId = statuses.first?.id