Fix multiple timeline refresh on launch close #555

This commit is contained in:
Thomas Ricouard 2023-01-31 12:17:03 +01:00
parent 22af2db36c
commit c88ef750f0

View file

@ -21,6 +21,7 @@ public struct TimelineView: View {
@StateObject private var viewModel = TimelineViewModel()
@State private var scrollProxy: ScrollViewProxy?
@State private var wasBackgrounded: Bool = false
@Binding var timeline: TimelineFilter
@Binding var scrollToTopSignal: Int
@ -99,9 +100,15 @@ public struct TimelineView: View {
.onChange(of: scenePhase, perform: { scenePhase in
switch scenePhase {
case .active:
if wasBackgrounded {
wasBackgrounded = false
Task {
await viewModel.fetchStatuses(userIntent: false)
}
}
case .background:
wasBackgrounded = true
default:
break
}