From 47436daaf25a13e57f0cfc9e657b7cc7ebd57c19 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Mon, 1 Jan 2024 21:29:03 +0100 Subject: [PATCH] Proper fix for looping timeline --- .../Status/List/StatusesListView.swift | 24 +++++++++---------- .../Timeline/View/TimelineViewModel.swift | 1 + .../Timeline/actors/TimelineDatasource.swift | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Packages/Status/Sources/Status/List/StatusesListView.swift b/Packages/Status/Sources/Status/List/StatusesListView.swift index db3c1c15..e970881e 100644 --- a/Packages/Status/Sources/Status/List/StatusesListView.swift +++ b/Packages/Status/Sources/Status/List/StatusesListView.swift @@ -48,19 +48,17 @@ public struct StatusesListView: View where Fetcher: StatusesFetcher { case let .display(statuses, nextPageState): ForEach(statuses, id: \.viewId) { status in - if !status.isHidden { - StatusRowView(viewModel: StatusRowViewModel(status: status, - client: client, - routerPath: routerPath, - isRemote: isRemote)) - .id(status.id) - .onAppear { - fetcher.statusDidAppear(status: status) - } - .onDisappear { - fetcher.statusDidDisappear(status: status) - } - } + StatusRowView(viewModel: StatusRowViewModel(status: status, + client: client, + routerPath: routerPath, + isRemote: isRemote)) + .id(status.id) + .onAppear { + fetcher.statusDidAppear(status: status) + } + .onDisappear { + fetcher.statusDidDisappear(status: status) + } } switch nextPageState { case .hasNextPage: diff --git a/Packages/Timeline/Sources/Timeline/View/TimelineViewModel.swift b/Packages/Timeline/Sources/Timeline/View/TimelineViewModel.swift index b3e3275e..dbcdcf8d 100644 --- a/Packages/Timeline/Sources/Timeline/View/TimelineViewModel.swift +++ b/Packages/Timeline/Sources/Timeline/View/TimelineViewModel.swift @@ -269,6 +269,7 @@ extension TimelineViewModel: StatusesFetcher { StatusDataControllerProvider.shared.updateDataControllers(for: statuses, client: client) await datasource.set(statuses) + statuses = await datasource.get() await cacheHome() withAnimation { diff --git a/Packages/Timeline/Sources/Timeline/actors/TimelineDatasource.swift b/Packages/Timeline/Sources/Timeline/actors/TimelineDatasource.swift index 3f554087..79c93e12 100644 --- a/Packages/Timeline/Sources/Timeline/actors/TimelineDatasource.swift +++ b/Packages/Timeline/Sources/Timeline/actors/TimelineDatasource.swift @@ -9,7 +9,7 @@ actor TimelineDatasource { } func get() -> [Status] { - statuses + statuses.filter{ !$0.isHidden } } func count() -> Int {