From 45575c49ad9fa007d6c665cb20b763ba2d18e63f Mon Sep 17 00:00:00 2001 From: Tomas Strba Date: Fri, 1 Nov 2024 14:10:01 +0100 Subject: [PATCH] SuggestionResult refactored --- .../ViewModel/SuggestionContainerViewModel.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/Suggestions/ViewModel/SuggestionContainerViewModel.swift b/DuckDuckGo/Suggestions/ViewModel/SuggestionContainerViewModel.swift index e175978f08..2324502656 100644 --- a/DuckDuckGo/Suggestions/ViewModel/SuggestionContainerViewModel.swift +++ b/DuckDuckGo/Suggestions/ViewModel/SuggestionContainerViewModel.swift @@ -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 } }