diff options
| author | Fuwn <[email protected]> | 2025-07-11 07:00:55 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-07-11 07:00:55 -0700 |
| commit | 2fb3174b8f36dcd5b2c7580638b94b1b4bdedbd1 (patch) | |
| tree | 720054948eb5bfb23e5ca01b8ae603f899fe9d8a | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-2fb3174b8f36dcd5b2c7580638b94b1b4bdedbd1.tar.xz sora-testing-2fb3174b8f36dcd5b2c7580638b94b1b4bdedbd1.zip | |
feat: Development commit
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 192b40f..a942a93 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -177,6 +177,9 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length } .navigationDestination(for: BooruPost.self) { post in PostDetailsView(post: post) + .onDisappear { + updateViewState(for: queryID, scrollPosition: scrollPosition.wrappedValue) + } } .onChange(of: isSearchablePresented) { _, isPresented in if !isPresented, manager.searchText.isEmpty, !manager.isNavigatingHistory { @@ -209,6 +212,10 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length manager.posts = state.posts manager.currentPage = state.currentPage manager.selectedPost = state.selectedPost + + DispatchQueue.main.async { + scrollPosition.wrappedValue = state.scrollPosition + } } else { manager.posts = [] manager.currentPage = 1 @@ -392,6 +399,7 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length currentPage: Int? = nil, selectedPost: BooruPost? = nil, resetSelectedPost: Bool = false, + scrollPosition: BooruPost.ID? = nil ) { let wasNewlyCreated = viewStates[queryID] == nil var state = viewStates[queryID] ?? PostGridViewState() @@ -406,6 +414,10 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length state.selectedPost = nil } + if let scrollPosition { + state.scrollPosition = scrollPosition + } + viewStates[queryID] = state if wasNewlyCreated { |