popular sites autocomplete setting

This commit is contained in:
Fabian Freund
2026-08-04 16:27:01 +02:00
parent c3a4a5bb52
commit c969821343
6 changed files with 80 additions and 2 deletions
@@ -34,7 +34,8 @@ class EngineSuggestions extends _$EngineSuggestions {
/// autocomplete (history/top-domains); when that yields nothing, falls back
/// to a popular-domain prefix match from the bundled Tranco-derived
/// `sites.db` so typing "git" still completes to "github.com" without any
/// local history.
/// local history. The fallback can be turned off via the
/// `popularSitesAutocompleteEnabled` setting.
Future<String?> getAutocompleteSuggestion(String query) async {
final engineResult = await ref
.read(engineSuggestionsServiceProvider)
@@ -47,6 +48,16 @@ class EngineSuggestions extends _$EngineSuggestions {
if (!ref.mounted) return null;
final popularSitesEnabled = ref.read(
generalSettingsWithDefaultsProvider.select(
(s) => s.popularSitesAutocompleteEnabled,
),
);
if (!popularSitesEnabled) {
return null;
}
final popularSites = await ref
.read(popularSitesRepositoryProvider.notifier)
.searchByPrefix(query, limit: 1);
@@ -33,7 +33,7 @@ final class EngineSuggestionsProvider
EngineSuggestions create() => EngineSuggestions();
}
String _$engineSuggestionsHash() => r'4918e80a1e7dfb59fe67d0895e62a39f2704851f';
String _$engineSuggestionsHash() => r'b2bc587d8df12b5614e2c00494a0d666e2c30746';
abstract class _$EngineSuggestions
extends $StreamNotifier<List<GeckoSuggestion>> {