popular sites autocomplete setting
This commit is contained in:
+12
-1
@@ -34,7 +34,8 @@ class EngineSuggestions extends _$EngineSuggestions {
|
|||||||
/// autocomplete (history/top-domains); when that yields nothing, falls back
|
/// autocomplete (history/top-domains); when that yields nothing, falls back
|
||||||
/// to a popular-domain prefix match from the bundled Tranco-derived
|
/// to a popular-domain prefix match from the bundled Tranco-derived
|
||||||
/// `sites.db` so typing "git" still completes to "github.com" without any
|
/// `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 {
|
Future<String?> getAutocompleteSuggestion(String query) async {
|
||||||
final engineResult = await ref
|
final engineResult = await ref
|
||||||
.read(engineSuggestionsServiceProvider)
|
.read(engineSuggestionsServiceProvider)
|
||||||
@@ -47,6 +48,16 @@ class EngineSuggestions extends _$EngineSuggestions {
|
|||||||
|
|
||||||
if (!ref.mounted) return null;
|
if (!ref.mounted) return null;
|
||||||
|
|
||||||
|
final popularSitesEnabled = ref.read(
|
||||||
|
generalSettingsWithDefaultsProvider.select(
|
||||||
|
(s) => s.popularSitesAutocompleteEnabled,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!popularSitesEnabled) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final popularSites = await ref
|
final popularSites = await ref
|
||||||
.read(popularSitesRepositoryProvider.notifier)
|
.read(popularSitesRepositoryProvider.notifier)
|
||||||
.searchByPrefix(query, limit: 1);
|
.searchByPrefix(query, limit: 1);
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ final class EngineSuggestionsProvider
|
|||||||
EngineSuggestions create() => EngineSuggestions();
|
EngineSuggestions create() => EngineSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$engineSuggestionsHash() => r'4918e80a1e7dfb59fe67d0895e62a39f2704851f';
|
String _$engineSuggestionsHash() => r'b2bc587d8df12b5614e2c00494a0d666e2c30746';
|
||||||
|
|
||||||
abstract class _$EngineSuggestions
|
abstract class _$EngineSuggestions
|
||||||
extends $StreamNotifier<List<GeckoSuggestion>> {
|
extends $StreamNotifier<List<GeckoSuggestion>> {
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ const List<SettingsSectionDefinition> searchSettingsSections = [
|
|||||||
keywords: ['submit', 'keyboard', 'suggestions'],
|
keywords: ['submit', 'keyboard', 'suggestions'],
|
||||||
child: _AcceptSuggestionOnSubmitTile(),
|
child: _AcceptSuggestionOnSubmitTile(),
|
||||||
),
|
),
|
||||||
|
SettingsEntryDefinition(
|
||||||
|
title: 'Popular site suggestions',
|
||||||
|
subtitle: 'Complete typed text with well-known domains',
|
||||||
|
keywords: ['popular sites', 'domains', 'ghost text', 'autocomplete'],
|
||||||
|
child: _PopularSitesAutocompleteTile(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SettingsSectionDefinition(
|
SettingsSectionDefinition(
|
||||||
@@ -387,6 +393,36 @@ class _AcceptSuggestionOnSubmitTile extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _PopularSitesAutocompleteTile extends HookConsumerWidget {
|
||||||
|
const _PopularSitesAutocompleteTile();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final popularSitesAutocompleteEnabled = ref.watch(
|
||||||
|
generalSettingsWithDefaultsProvider.select(
|
||||||
|
(s) => s.popularSitesAutocompleteEnabled,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return SwitchListTile.adaptive(
|
||||||
|
title: const Text('Popular site suggestions'),
|
||||||
|
subtitle: const Text(
|
||||||
|
'Complete typed text with well-known domains when your history has no match',
|
||||||
|
),
|
||||||
|
secondary: const Icon(MdiIcons.web),
|
||||||
|
value: popularSitesAutocompleteEnabled,
|
||||||
|
onChanged: (value) async {
|
||||||
|
await ref
|
||||||
|
.read(saveGeneralSettingsControllerProvider.notifier)
|
||||||
|
.save(
|
||||||
|
(currentSettings) => currentSettings.copyWith
|
||||||
|
.popularSitesAutocompleteEnabled(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _LocalIndexEnabledTile extends HookConsumerWidget {
|
class _LocalIndexEnabledTile extends HookConsumerWidget {
|
||||||
const _LocalIndexEnabledTile();
|
const _LocalIndexEnabledTile();
|
||||||
|
|
||||||
|
|||||||
@@ -264,6 +264,11 @@ class GeneralSettings with FastEquatable {
|
|||||||
/// accept and complete an inline search suggestion. Defaults to false.
|
/// accept and complete an inline search suggestion. Defaults to false.
|
||||||
final bool acceptSuggestionOnSubmit;
|
final bool acceptSuggestionOnSubmit;
|
||||||
|
|
||||||
|
/// Whether the bundled Tranco-derived popular-domain list may supply the
|
||||||
|
/// omnibar's inline ghost-text completion when the engine's own autocomplete
|
||||||
|
/// (history/top domains) has no match. Defaults to true.
|
||||||
|
final bool popularSitesAutocompleteEnabled;
|
||||||
|
|
||||||
/// Whether dark mode should use pure-black ("OLED"/high-contrast) surfaces.
|
/// Whether dark mode should use pure-black ("OLED"/high-contrast) surfaces.
|
||||||
/// Only takes effect when the effective brightness is dark. Defaults to false.
|
/// Only takes effect when the effective brightness is dark. Defaults to false.
|
||||||
final bool pureBlack;
|
final bool pureBlack;
|
||||||
@@ -357,6 +362,7 @@ class GeneralSettings with FastEquatable {
|
|||||||
required this.enableLocalSearchIndex,
|
required this.enableLocalSearchIndex,
|
||||||
required this.indexPrivateTabs,
|
required this.indexPrivateTabs,
|
||||||
required this.acceptSuggestionOnSubmit,
|
required this.acceptSuggestionOnSubmit,
|
||||||
|
required this.popularSitesAutocompleteEnabled,
|
||||||
required this.pureBlack,
|
required this.pureBlack,
|
||||||
required this.globalDesktopMode,
|
required this.globalDesktopMode,
|
||||||
required this.desktopModeSites,
|
required this.desktopModeSites,
|
||||||
@@ -433,6 +439,7 @@ class GeneralSettings with FastEquatable {
|
|||||||
bool? enableLocalSearchIndex,
|
bool? enableLocalSearchIndex,
|
||||||
bool? indexPrivateTabs,
|
bool? indexPrivateTabs,
|
||||||
bool? acceptSuggestionOnSubmit,
|
bool? acceptSuggestionOnSubmit,
|
||||||
|
bool? popularSitesAutocompleteEnabled,
|
||||||
bool? pureBlack,
|
bool? pureBlack,
|
||||||
bool? globalDesktopMode,
|
bool? globalDesktopMode,
|
||||||
List<String>? desktopModeSites,
|
List<String>? desktopModeSites,
|
||||||
@@ -520,6 +527,8 @@ class GeneralSettings with FastEquatable {
|
|||||||
enableLocalSearchIndex = enableLocalSearchIndex ?? true,
|
enableLocalSearchIndex = enableLocalSearchIndex ?? true,
|
||||||
indexPrivateTabs = indexPrivateTabs ?? false,
|
indexPrivateTabs = indexPrivateTabs ?? false,
|
||||||
acceptSuggestionOnSubmit = acceptSuggestionOnSubmit ?? true,
|
acceptSuggestionOnSubmit = acceptSuggestionOnSubmit ?? true,
|
||||||
|
popularSitesAutocompleteEnabled =
|
||||||
|
popularSitesAutocompleteEnabled ?? true,
|
||||||
pureBlack = pureBlack ?? false,
|
pureBlack = pureBlack ?? false,
|
||||||
globalDesktopMode = globalDesktopMode ?? false,
|
globalDesktopMode = globalDesktopMode ?? false,
|
||||||
desktopModeSites = desktopModeSites ?? const [],
|
desktopModeSites = desktopModeSites ?? const [],
|
||||||
@@ -687,6 +696,7 @@ class GeneralSettings with FastEquatable {
|
|||||||
enableLocalSearchIndex,
|
enableLocalSearchIndex,
|
||||||
indexPrivateTabs,
|
indexPrivateTabs,
|
||||||
acceptSuggestionOnSubmit,
|
acceptSuggestionOnSubmit,
|
||||||
|
popularSitesAutocompleteEnabled,
|
||||||
pureBlack,
|
pureBlack,
|
||||||
globalDesktopMode,
|
globalDesktopMode,
|
||||||
desktopModeSites,
|
desktopModeSites,
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ abstract class _$GeneralSettingsCWProxy {
|
|||||||
|
|
||||||
GeneralSettings acceptSuggestionOnSubmit(bool acceptSuggestionOnSubmit);
|
GeneralSettings acceptSuggestionOnSubmit(bool acceptSuggestionOnSubmit);
|
||||||
|
|
||||||
|
GeneralSettings popularSitesAutocompleteEnabled(
|
||||||
|
bool popularSitesAutocompleteEnabled,
|
||||||
|
);
|
||||||
|
|
||||||
GeneralSettings pureBlack(bool pureBlack);
|
GeneralSettings pureBlack(bool pureBlack);
|
||||||
|
|
||||||
GeneralSettings globalDesktopMode(bool globalDesktopMode);
|
GeneralSettings globalDesktopMode(bool globalDesktopMode);
|
||||||
@@ -252,6 +256,7 @@ abstract class _$GeneralSettingsCWProxy {
|
|||||||
bool enableLocalSearchIndex,
|
bool enableLocalSearchIndex,
|
||||||
bool indexPrivateTabs,
|
bool indexPrivateTabs,
|
||||||
bool acceptSuggestionOnSubmit,
|
bool acceptSuggestionOnSubmit,
|
||||||
|
bool popularSitesAutocompleteEnabled,
|
||||||
bool pureBlack,
|
bool pureBlack,
|
||||||
bool globalDesktopMode,
|
bool globalDesktopMode,
|
||||||
List<String> desktopModeSites,
|
List<String> desktopModeSites,
|
||||||
@@ -563,6 +568,11 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
|||||||
GeneralSettings acceptSuggestionOnSubmit(bool acceptSuggestionOnSubmit) =>
|
GeneralSettings acceptSuggestionOnSubmit(bool acceptSuggestionOnSubmit) =>
|
||||||
call(acceptSuggestionOnSubmit: acceptSuggestionOnSubmit);
|
call(acceptSuggestionOnSubmit: acceptSuggestionOnSubmit);
|
||||||
|
|
||||||
|
@override
|
||||||
|
GeneralSettings popularSitesAutocompleteEnabled(
|
||||||
|
bool popularSitesAutocompleteEnabled,
|
||||||
|
) => call(popularSitesAutocompleteEnabled: popularSitesAutocompleteEnabled);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
GeneralSettings pureBlack(bool pureBlack) => call(pureBlack: pureBlack);
|
GeneralSettings pureBlack(bool pureBlack) => call(pureBlack: pureBlack);
|
||||||
|
|
||||||
@@ -658,6 +668,7 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
|||||||
Object? enableLocalSearchIndex = const $CopyWithPlaceholder(),
|
Object? enableLocalSearchIndex = const $CopyWithPlaceholder(),
|
||||||
Object? indexPrivateTabs = const $CopyWithPlaceholder(),
|
Object? indexPrivateTabs = const $CopyWithPlaceholder(),
|
||||||
Object? acceptSuggestionOnSubmit = const $CopyWithPlaceholder(),
|
Object? acceptSuggestionOnSubmit = const $CopyWithPlaceholder(),
|
||||||
|
Object? popularSitesAutocompleteEnabled = const $CopyWithPlaceholder(),
|
||||||
Object? pureBlack = const $CopyWithPlaceholder(),
|
Object? pureBlack = const $CopyWithPlaceholder(),
|
||||||
Object? globalDesktopMode = const $CopyWithPlaceholder(),
|
Object? globalDesktopMode = const $CopyWithPlaceholder(),
|
||||||
Object? desktopModeSites = const $CopyWithPlaceholder(),
|
Object? desktopModeSites = const $CopyWithPlaceholder(),
|
||||||
@@ -1068,6 +1079,12 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
|||||||
? _value.acceptSuggestionOnSubmit
|
? _value.acceptSuggestionOnSubmit
|
||||||
// ignore: cast_nullable_to_non_nullable
|
// ignore: cast_nullable_to_non_nullable
|
||||||
: acceptSuggestionOnSubmit as bool,
|
: acceptSuggestionOnSubmit as bool,
|
||||||
|
popularSitesAutocompleteEnabled:
|
||||||
|
popularSitesAutocompleteEnabled == const $CopyWithPlaceholder() ||
|
||||||
|
popularSitesAutocompleteEnabled == null
|
||||||
|
? _value.popularSitesAutocompleteEnabled
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: popularSitesAutocompleteEnabled as bool,
|
||||||
pureBlack: pureBlack == const $CopyWithPlaceholder() || pureBlack == null
|
pureBlack: pureBlack == const $CopyWithPlaceholder() || pureBlack == null
|
||||||
? _value.pureBlack
|
? _value.pureBlack
|
||||||
// ignore: cast_nullable_to_non_nullable
|
// ignore: cast_nullable_to_non_nullable
|
||||||
@@ -1243,6 +1260,8 @@ GeneralSettings _$GeneralSettingsFromJson(
|
|||||||
enableLocalSearchIndex: json['enableLocalSearchIndex'] as bool?,
|
enableLocalSearchIndex: json['enableLocalSearchIndex'] as bool?,
|
||||||
indexPrivateTabs: json['indexPrivateTabs'] as bool?,
|
indexPrivateTabs: json['indexPrivateTabs'] as bool?,
|
||||||
acceptSuggestionOnSubmit: json['acceptSuggestionOnSubmit'] as bool?,
|
acceptSuggestionOnSubmit: json['acceptSuggestionOnSubmit'] as bool?,
|
||||||
|
popularSitesAutocompleteEnabled:
|
||||||
|
json['popularSitesAutocompleteEnabled'] as bool?,
|
||||||
pureBlack: json['pureBlack'] as bool?,
|
pureBlack: json['pureBlack'] as bool?,
|
||||||
globalDesktopMode: json['globalDesktopMode'] as bool?,
|
globalDesktopMode: json['globalDesktopMode'] as bool?,
|
||||||
desktopModeSites: (json['desktopModeSites'] as List<dynamic>?)
|
desktopModeSites: (json['desktopModeSites'] as List<dynamic>?)
|
||||||
@@ -1340,6 +1359,7 @@ Map<String, dynamic> _$GeneralSettingsToJson(
|
|||||||
'enableLocalSearchIndex': instance.enableLocalSearchIndex,
|
'enableLocalSearchIndex': instance.enableLocalSearchIndex,
|
||||||
'indexPrivateTabs': instance.indexPrivateTabs,
|
'indexPrivateTabs': instance.indexPrivateTabs,
|
||||||
'acceptSuggestionOnSubmit': instance.acceptSuggestionOnSubmit,
|
'acceptSuggestionOnSubmit': instance.acceptSuggestionOnSubmit,
|
||||||
|
'popularSitesAutocompleteEnabled': instance.popularSitesAutocompleteEnabled,
|
||||||
'pureBlack': instance.pureBlack,
|
'pureBlack': instance.pureBlack,
|
||||||
'globalDesktopMode': instance.globalDesktopMode,
|
'globalDesktopMode': instance.globalDesktopMode,
|
||||||
'desktopModeSites': instance.desktopModeSites,
|
'desktopModeSites': instance.desktopModeSites,
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ const generalSettingColumnTypes = <String, DriftSqlType>{
|
|||||||
'enableLocalSearchIndex': DriftSqlType.bool,
|
'enableLocalSearchIndex': DriftSqlType.bool,
|
||||||
'indexPrivateTabs': DriftSqlType.bool,
|
'indexPrivateTabs': DriftSqlType.bool,
|
||||||
'acceptSuggestionOnSubmit': DriftSqlType.bool,
|
'acceptSuggestionOnSubmit': DriftSqlType.bool,
|
||||||
|
'popularSitesAutocompleteEnabled': DriftSqlType.bool,
|
||||||
'pureBlack': DriftSqlType.bool,
|
'pureBlack': DriftSqlType.bool,
|
||||||
'showSearchCloseButton': DriftSqlType.bool,
|
'showSearchCloseButton': DriftSqlType.bool,
|
||||||
'homeTarget': DriftSqlType.string,
|
'homeTarget': DriftSqlType.string,
|
||||||
|
|||||||
Reference in New Issue
Block a user