summaryrefslogtreecommitdiff
path: root/Sora/Views/Post/Grid
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-08-05 21:44:18 +0200
committerFuwn <[email protected]>2025-08-05 21:44:18 +0200
commitaca046f9c36a87317fdbb76fee336e3b5920f9ac (patch)
treef78eeb9b9fe9d08eeff89ff3d3cc722188544e55 /Sora/Views/Post/Grid
parentfeat: Development commit (diff)
downloadsora-testing-aca046f9c36a87317fdbb76fee336e3b5920f9ac.tar.xz
sora-testing-aca046f9c36a87317fdbb76fee336e3b5920f9ac.zip
feat: Development commit
Diffstat (limited to 'Sora/Views/Post/Grid')
-rw-r--r--Sora/Views/Post/Grid/PostGridView.swift18
1 files 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<Void, Never>?
+ @State private var lastScrollCaptureTime: CFTimeInterval = CFAbsoluteTimeGetCurrent()
+
+ private var throttledScrollID: Binding<String?> {
+ 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,