From aca046f9c36a87317fdbb76fee336e3b5920f9ac Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 5 Aug 2025 21:44:18 +0200 Subject: feat: Development commit --- Sora/Views/Post/Grid/PostGridView.swift | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index a63bf97..955abd4 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -19,6 +19,21 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length @State private var scrollID: String? @State private var cachedColumnsData: ColumnsDataCache? @State private var scrollDebounceTask: Task? + @State private var lastScrollCaptureTime: CFTimeInterval = CFAbsoluteTimeGetCurrent() + + private var throttledScrollID: Binding { + Binding( + get: { scrollID }, + set: { newValue in + let now = CFAbsoluteTimeGetCurrent() + + if now - lastScrollCaptureTime > 0.5 { + lastScrollCaptureTime = now + scrollID = newValue + } + } + ) + } @Environment(\.isSearching) private var isSearching @@ -145,8 +160,7 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length .id(queryID) .transition(.opacity) } - .scrollPosition(id: $scrollID, anchor: .top) - .scrollTargetBehavior(.viewAligned) + .scrollPosition(id: throttledScrollID, anchor: .top) #if os(iOS) .searchable( text: $manager.searchText, -- cgit v1.2.3