summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-09-11 23:50:52 -0700
committerFuwn <[email protected]>2025-09-11 23:50:52 -0700
commitbba26c05db02e656ce35b1b972e7db2f361459d1 (patch)
treef982d5b4eda9f8e573eb04a40bf744ba1b28919f
parentfeat: Development commit (diff)
downloadsora-testing-bba26c05db02e656ce35b1b972e7db2f361459d1.tar.xz
sora-testing-bba26c05db02e656ce35b1b972e7db2f361459d1.zip
feat: Development commit
-rw-r--r--Sora/Views/Post/Grid/PostGridView.swift31
1 files 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<Void, Never>?
+ @State private var previousNavigationPathCount = 0
init(
selectedTab: Binding<Int>, navigationPath: Binding<NavigationPath>, 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,