diff options
| author | Fuwn <[email protected]> | 2025-09-11 15:00:22 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-11 15:00:22 -0700 |
| commit | 155a855477539ec4914a0be620456e458cf1464e (patch) | |
| tree | eaf0f3bf4b6db98e718e061ee757db8eafcb3f68 /Sora/Views/Post/Grid/PostGridView.swift | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-155a855477539ec4914a0be620456e458cf1464e.tar.xz sora-testing-155a855477539ec4914a0be620456e458cf1464e.zip | |
feat: Development commit
Diffstat (limited to 'Sora/Views/Post/Grid/PostGridView.swift')
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 518b305..025c3d2 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -253,14 +253,19 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length await performLocalSearch() } } else { - currentLocalTask = Task(priority: .userInitiated) { - await fetchLocalPosts( - page: 1, - tags: localSearchText.components(separatedBy: .whitespaces).filter { component in - !component.isEmpty - }, - replace: true - ) + let currentTags = localSearchText.components(separatedBy: .whitespaces).filter { !$0.isEmpty } + let hasPosts = !localPosts.isEmpty + let initialTags = initialTag.components(separatedBy: .whitespaces).filter { !$0.isEmpty } + let needsFetch = !hasPosts || currentTags != initialTags + + if needsFetch { + currentLocalTask = Task(priority: .userInitiated) { + await fetchLocalPosts( + page: 1, + tags: currentTags, + replace: true + ) + } } } } |