Timeline: Fix trending refreshing when navigating back
This commit is contained in:
parent
6dcce79379
commit
4bc2672583
|
@ -115,7 +115,7 @@ public struct TimelineView: View {
|
|||
}
|
||||
.refreshable {
|
||||
HapticManager.shared.fireHaptic(of: .dataRefresh(intensity: 0.3))
|
||||
await viewModel.fetchNewestStatuses()
|
||||
await viewModel.pullToRefresh()
|
||||
HapticManager.shared.fireHaptic(of: .dataRefresh(intensity: 0.7))
|
||||
}
|
||||
.onChange(of: watcher.latestEvent?.id) { _ in
|
||||
|
|
|
@ -156,13 +156,19 @@ extension TimelineViewModel {
|
|||
// MARK: - StatusesFetcher
|
||||
|
||||
extension TimelineViewModel: StatusesFetcher {
|
||||
func pullToRefresh() async {
|
||||
if !timeline.supportNewestPagination {
|
||||
await reset()
|
||||
}
|
||||
await fetchNewestStatuses()
|
||||
}
|
||||
|
||||
func fetchNewestStatuses() async {
|
||||
guard let client else { return }
|
||||
do {
|
||||
if await datasource.isEmpty || !timeline.supportNewestPagination {
|
||||
await reset()
|
||||
if await datasource.isEmpty {
|
||||
try await fetchFirstPage(client: client)
|
||||
} else if let latest = await datasource.get().first {
|
||||
} else if let latest = await datasource.get().first, timeline.supportNewestPagination {
|
||||
try await fetchNewPagesFrom(latestStatus: latest, client: client)
|
||||
}
|
||||
} catch {
|
||||
|
|
Loading…
Reference in New Issue