Skip to content

Commit

Permalink
SuggestionResult refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba committed Nov 1, 2024
1 parent 895ce8c commit 45575c4
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,18 @@ final class SuggestionContainerViewModel {
}

func removeSuggestionFromResult(suggestion: Suggestion) {
suggestionContainer.result?.topHits = suggestionContainer.result?.topHits.filter({
let topHits = suggestionContainer.result?.topHits.filter({
!($0 == suggestion && $0.isHistoryEntry)
}) ?? []
suggestionContainer.result?.localSuggestions = suggestionContainer.result?.localSuggestions.filter({
let duckduckgoSuggestions = suggestionContainer.result?.duckduckgoSuggestions ?? []
let localSuggestions = suggestionContainer.result?.localSuggestions.filter({
!($0 == suggestion && $0.isHistoryEntry)
}) ?? []
let result = SuggestionResult(topHits: topHits,
duckduckgoSuggestions: duckduckgoSuggestions,
localSuggestions: localSuggestions)

suggestionContainer.result = result
}

}

0 comments on commit 45575c4

Please sign in to comment.