From bba26c05db02e656ce35b1b972e7db2f361459d1 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 11 Sep 2025 23:50:52 -0700 Subject: feat: Development commit --- Sora/Views/Post/Grid/PostGridView.swift | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 3c7ebe3..25b21d6 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -24,6 +24,7 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length @State private var localError: Error? @State private var hasAppearedBefore = false @State private var currentLocalTask: Task? + @State private var previousNavigationPathCount = 0 init( selectedTab: Binding, navigationPath: Binding, initialTag: String? = nil @@ -221,14 +222,6 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length } } } - .navigationDestination(for: PostWithContext.self) { context in - PostDetailsView( - post: context.post, - navigationPath: $navigationPath, - posts: context.posts, - baseSearchText: context.baseSearchText - ) - } .onChange(of: isSearchablePresented) { _, isPresented in if !isPresented, searchText.wrappedValue.isEmpty, !manager.isNavigatingHistory { Task(priority: .userInitiated) { @@ -240,14 +233,14 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length } } } - .onChange(of: navigationPath) { _, _ in - if initialTag == nil && !manager.isNavigatingHistory && !manager.isLoading { - Task(priority: .userInitiated) { - await manager.fetchPosts(page: 1, tags: manager.tags, replace: true) - } - } + .onChange(of: navigationPath) { _, newPath in + let currentPathCount = newPath.count + + previousNavigationPathCount = currentPathCount } .onAppear { + previousNavigationPathCount = navigationPath.count + if let initialTag { if localSearchText.isEmpty || !hasAppearedBefore { localSearchText = initialTag @@ -280,7 +273,7 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length } } } else { - if !manager.isNavigatingHistory && !manager.isLoading { + if manager.posts.isEmpty && !manager.isNavigatingHistory && !manager.isLoading { Task(priority: .userInitiated) { await manager.fetchPosts(page: 1, tags: manager.tags, replace: true) } @@ -476,13 +469,15 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length } private func waterfallGridContent(post: BooruPost) -> some View { - NavigationLink( - value: PostWithContext( + Button(action: { + let context = PostWithContext( post: post, posts: initialTag != nil ? localPosts : nil, baseSearchText: initialTag != nil ? localSearchText : nil ) - ) { + + navigationPath.append(context) + }) { PostGridThumbnailView( post: post, posts: activePosts, -- cgit v1.2.3