summaryrefslogtreecommitdiff
path: root/Sora/Views/Post/Grid/PostGridView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Sora/Views/Post/Grid/PostGridView.swift')
-rw-r--r--Sora/Views/Post/Grid/PostGridView.swift32
1 files changed, 22 insertions, 10 deletions
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift
index 4aa4b39..117da87 100644
--- a/Sora/Views/Post/Grid/PostGridView.swift
+++ b/Sora/Views/Post/Grid/PostGridView.swift
@@ -69,14 +69,16 @@ struct PostGridView: View {
return
}
- manager.performSearch(settings: settings)
+ Task(priority: .userInitiated) {
+ await manager.performSearch(settings: settings)
+ }
}
.navigationDestination(for: BooruPost.self) { post in
PostDetailsView(post: post)
}
.onChange(of: isSearchablePresented) { _, isPresented in
if !isPresented, manager.searchText.isEmpty, !manager.isNavigatingHistory {
- manager.performSearch()
+ Task(priority: .userInitiated) { await manager.performSearch() }
}
}
.onChange(of: manager.posts) { _, newPosts in
@@ -105,11 +107,13 @@ struct PostGridView: View {
manager.posts = []
manager.currentPage = 1
- manager.fetchPosts(
- page: 1,
- tags: manager.searchHistory[newIndex].tags,
- replace: true
- )
+ Task(priority: .userInitiated) {
+ await manager.fetchPosts(
+ page: 1,
+ tags: manager.searchHistory[newIndex].tags,
+ replace: true
+ )
+ }
}
}
.toolbar {
@@ -144,7 +148,13 @@ struct PostGridView: View {
}
PlatformSpecificToolbarItem {
- Button(action: { Task { manager.loadNextPage() } }) {
+ Button(
+ action: {
+ Task(priority: .userInitiated) {
+ await manager.loadNextPage()
+ }
+ }
+ ) {
Label(
"Manually Load Next Page",
systemImage: "arrow.down.to.line"
@@ -176,9 +186,11 @@ struct PostGridView: View {
.navigationTitle("Posts")
.refreshable {
manager.clearCachedPages()
- manager.fetchPosts(page: 1, tags: manager.tags, replace: true)
+
+ Task(priority: .userInitiated) {
+ await manager.fetchPosts(page: 1, tags: manager.tags, replace: true)
+ }
}
- .scrollDisabled(manager.isLoading)
.sheet(isPresented: $isSearchHistoryPresented) {
PostGridSearchHistoryView(
selectedTab: $selectedTab,