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): case let .display(statuses, nextPageState):
ForEach(statuses, id: \.viewId) { status in ForEach(statuses, id: \.viewId) { status in
if !status.isHidden { StatusRowView(viewModel: StatusRowViewModel(status: status,
StatusRowView(viewModel: StatusRowViewModel(status: status, client: client,
client: client, routerPath: routerPath,
routerPath: routerPath, isRemote: isRemote))
isRemote: isRemote)) .id(status.id)
.id(status.id) .onAppear {
.onAppear { fetcher.statusDidAppear(status: status)
fetcher.statusDidAppear(status: status) }
} .onDisappear {
.onDisappear { fetcher.statusDidDisappear(status: status)
fetcher.statusDidDisappear(status: status) }
}
}
} }
switch nextPageState { switch nextPageState {
case .hasNextPage: case .hasNextPage:

View File

@ -269,6 +269,7 @@ extension TimelineViewModel: StatusesFetcher {
StatusDataControllerProvider.shared.updateDataControllers(for: statuses, client: client) StatusDataControllerProvider.shared.updateDataControllers(for: statuses, client: client)
await datasource.set(statuses) await datasource.set(statuses)
statuses = await datasource.get()
await cacheHome() await cacheHome()
withAnimation { withAnimation {

View File

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