diff options
| author | Fuwn <[email protected]> | 2025-03-01 19:53:45 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-03-01 19:53:45 -0800 |
| commit | 774087d67eb231cb603abc73069cd74f4aafefe3 (patch) | |
| tree | 8f36b1b783d0ac9845ac2485a624ff775220952d /Sora/Views/Post/Grid/PostGridView.swift | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-774087d67eb231cb603abc73069cd74f4aafefe3.tar.xz sora-testing-774087d67eb231cb603abc73069cd74f4aafefe3.zip | |
feat: Development commit
Diffstat (limited to 'Sora/Views/Post/Grid/PostGridView.swift')
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index d5d583b..dc6546d 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -31,9 +31,9 @@ struct PostGridView: View { } .searchable(text: $manager.searchText, prompt: "Tags") .searchSuggestions { - if settings.searchSuggestionsMode == .tags { + if settings.searchSuggestionsMode != .disabled { SearchSuggestionsView( - tags: manager.allTags, + items: searchSuggestionsItems(), searchText: $manager.searchText ) } @@ -127,4 +127,23 @@ struct PostGridView: View { } } } + + private func searchSuggestionsItems() -> [Either<BooruTag, BooruSearchQuery>] { + let items: [Either<BooruTag, BooruSearchQuery>] + + switch settings.searchSuggestionsMode { + case .tags: + items = manager.allTags + .map { Either<BooruTag, BooruSearchQuery>.left($0) } + + case .history: + items = settings.searchHistory + .map { Either<BooruTag, BooruSearchQuery>.right($0) } + + case .disabled: + items = [] + } + + return items + } } |