diff options
| author | Fuwn <[email protected]> | 2025-02-28 03:27:07 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-02-28 03:27:07 -0800 |
| commit | d4fd7e8d5f75f1ac7718aac6c1299c3ff740de75 (patch) | |
| tree | dfd4776c3a1bbe3b448310f9572d5949c80695a5 /Sora/Data/Settings | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-d4fd7e8d5f75f1ac7718aac6c1299c3ff740de75.tar.xz sora-testing-d4fd7e8d5f75f1ac7718aac6c1299c3ff740de75.zip | |
feat: Development commit
Diffstat (limited to 'Sora/Data/Settings')
| -rw-r--r-- | Sora/Data/Settings/SettingsManager.swift | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/Sora/Data/Settings/SettingsManager.swift b/Sora/Data/Settings/SettingsManager.swift index b46c333..6035de3 100644 --- a/Sora/Data/Settings/SettingsManager.swift +++ b/Sora/Data/Settings/SettingsManager.swift @@ -87,12 +87,6 @@ class SettingsManager: ObservableObject { self.searchHistory.append(query) } - func removeFromSearchHistory(_ query: BooruSearchQuery) { - if let index = self.searchHistory.firstIndex(of: query) { - self.searchHistory.remove(at: index) - } - } - private static func defaultRatingsData() -> Data { initializeRatingsData(enabledRatings: BooruRating.allCases) } @@ -178,4 +172,32 @@ class SettingsManager: ObservableObject { bookmarks = currentBookmarks } + + func removeSearchHistoryEntry(at index: IndexSet) { + var currentSearchHistory = searchHistory + + currentSearchHistory.remove(atOffsets: index) + + searchHistory = currentSearchHistory + } + + func removeSearchHistoryEntry(withTags tags: [String]) { + var currentSearchHistory = searchHistory + + currentSearchHistory.removeAll { query in + query.tags.contains(where: tags.contains) + } + + searchHistory = currentSearchHistory + } + + func removeSearchHistoryEntry(withID: UUID) { + var currentSearchHistory = searchHistory + + currentSearchHistory.removeAll { query in + query.id == withID + } + + searchHistory = currentSearchHistory + } } |