Proper fix for looping timeline

This commit is contained in:
Thomas Ricouard 2024-01-01 21:29:03 +01:00
parent 1e7c25993a
commit 47436daaf2
3 changed files with 13 additions and 14 deletions

View file

@ -48,19 +48,17 @@ public struct StatusesListView<Fetcher>: 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:

View file

@ -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 {

View file

@ -9,7 +9,7 @@ actor TimelineDatasource {
}
func get() -> [Status] {
statuses
statuses.filter{ !$0.isHidden }
}
func count() -> Int {