LeOS-Ice-browser/automation/iceraven/patches/suggestions_increase_number...

62 lines
4.8 KiB
Diff

diff --git a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/BookmarksStorageSuggestionProvider.kt b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/BookmarksStorageSuggestionProvider.kt
index 73252c1560..0544a51f59 100644
--- a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/BookmarksStorageSuggestionProvider.kt
+++ b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/BookmarksStorageSuggestionProvider.kt
@@ -86,7 +86,7 @@ class BookmarksStorageSuggestionProvider(
* @param query String to filter bookmarks' title or URL by.
*/
private suspend fun getBookmarksSuggestions(query: String) = bookmarksStorage
- .searchBookmarks(query, BOOKMARKS_SUGGESTION_LIMIT)
+ .searchBookmarks(query, BOOKMARKS_SUGGESTION_LIMIT * BOOKMARKS_RESULTS_TO_FILTER_SCALE_FACTOR)
.filter { it.url != null }
.distinctBy { it.url }
.sortedBy { it.guid }
diff --git a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/CombinedHistorySuggestionProvider.kt b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/CombinedHistorySuggestionProvider.kt
index 5d79e8caed..293a5cee78 100644
--- a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/CombinedHistorySuggestionProvider.kt
+++ b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/CombinedHistorySuggestionProvider.kt
@@ -145,7 +145,7 @@ class CombinedHistorySuggestionProvider(
* @param query String to filter bookmarks' title or URL by.
*/
private suspend fun getMetadataSuggestions(query: String) = historyMetadataStorage
- .queryHistoryMetadata(query, maxNumberOfSuggestions)
+ .queryHistoryMetadata(query, maxNumberOfSuggestions * COMBINED_HISTORY_RESULTS_TO_FILTER_SCALE_FACTOR)
.filter { it.totalViewTime > 0 }
.into(this@CombinedHistorySuggestionProvider, icons, loadUrlUseCase, showEditSuggestion)
@@ -169,7 +169,7 @@ class CombinedHistorySuggestionProvider(
* @param query String to filter history entry's title or URL by.
*/
private suspend fun getHistorySuggestions(query: String) = historyStorage
- .getSuggestions(query, maxNumberOfSuggestions)
+ .getSuggestions(query, maxNumberOfSuggestions * COMBINED_HISTORY_RESULTS_TO_FILTER_SCALE_FACTOR)
.sortedByDescending { it.score }
.distinctBy { it.id }
.into(this@CombinedHistorySuggestionProvider, icons, loadUrlUseCase, showEditSuggestion)
diff --git a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryMetadataSuggestionProvider.kt b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryMetadataSuggestionProvider.kt
index ad1d7590b7..512262ee9a 100644
--- a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryMetadataSuggestionProvider.kt
+++ b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryMetadataSuggestionProvider.kt
@@ -85,7 +85,7 @@ class HistoryMetadataSuggestionProvider(
* @param query String to filter history entry's title or URL by.
*/
private suspend fun getHistorySuggestions(query: String) = historyStorage
- .queryHistoryMetadata(query, maxNumberOfSuggestions)
+ .queryHistoryMetadata(query, maxNumberOfSuggestions * HISTORY_METADATA_RESULTS_TO_FILTER_SCALE_FACTOR)
.filter { it.totalViewTime > 0 }
/**
diff --git a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryStorageSuggestionProvider.kt b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryStorageSuggestionProvider.kt
index e9d56bede3..c95da08651 100644
--- a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryStorageSuggestionProvider.kt
+++ b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryStorageSuggestionProvider.kt
@@ -110,7 +110,7 @@ class HistoryStorageSuggestionProvider(
* @param query String to filter history entry's title or URL by.
*/
private fun getHistorySuggestions(query: String) = historyStorage
- .getSuggestions(query, maxNumberOfSuggestions)
+ .getSuggestions(query, maxNumberOfSuggestions * HISTORY_RESULTS_TO_FILTER_SCALE_FACTOR)
// In case of duplicates we want to pick the suggestion with the highest score.
// See: https://github.com/mozilla/application-services/issues/970
.sortedByDescending { it.score }