From eb80225bb0a2f9190e672529730e6036738102ea Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Fri, 3 Feb 2023 08:06:16 +0100 Subject: [PATCH] Mitigate #623 --- Packages/Timeline/Sources/Timeline/TimelineView.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Packages/Timeline/Sources/Timeline/TimelineView.swift b/Packages/Timeline/Sources/Timeline/TimelineView.swift index dd3bab6a..3b7f2bdd 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineView.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineView.swift @@ -21,6 +21,7 @@ public struct TimelineView: View { @StateObject private var viewModel = TimelineViewModel() @State private var wasBackgrounded: Bool = false + @State private var listOpacity: CGFloat = 1 @Binding var timeline: TimelineFilter @Binding var scrollToTopSignal: Int @@ -46,7 +47,8 @@ public struct TimelineView: View { StatusesListView(fetcher: viewModel) } } - .id(client.id) + .id(client.id + (viewModel.scrollToStatus ?? "")) + .opacity(listOpacity) .environment(\.defaultMinListRowHeight, 1) .listStyle(.plain) .scrollContentBackground(.hidden) @@ -58,7 +60,11 @@ public struct TimelineView: View { .onChange(of: viewModel.scrollToStatus) { statusId in if let statusId { viewModel.scrollToStatus = nil - proxy.scrollTo(statusId, anchor: .center) + listOpacity = 0 + DispatchQueue.main.async { + proxy.scrollTo(statusId, anchor: .top) + listOpacity = 1 + } } } .onChange(of: scrollToTopSignal, perform: { _ in