provider mounted hardenings
This commit is contained in:
@@ -53,6 +53,7 @@ class EngineBoundIntentStream extends _$EngineBoundIntentStream {
|
||||
@override
|
||||
Stream<SharedContent> build() {
|
||||
_streamController = StreamController();
|
||||
|
||||
ref.onDispose(() async {
|
||||
await _streamController.close();
|
||||
});
|
||||
|
||||
@@ -52,6 +52,8 @@ class BrowserAddonService extends _$BrowserAddonService {
|
||||
Future<bool> install(String addonGuid) async {
|
||||
try {
|
||||
final xpiUrl = await getAddonXpiUrl(addonGuid);
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
await ref.read(addonServiceProvider).installAddon(xpiUrl);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -42,7 +42,7 @@ final class BrowserAddonServiceProvider
|
||||
}
|
||||
|
||||
String _$browserAddonServiceHash() =>
|
||||
r'1dd73c322e712e1492d74f1af844d5b5cc8f81bb';
|
||||
r'3f2166251f02fe8c103cca93c02eb982b2800577';
|
||||
|
||||
abstract class _$BrowserAddonService extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
+24
-8
@@ -52,8 +52,8 @@ Future<PreferenceSettingGroup> _preferenceSettingGroup(
|
||||
Ref ref,
|
||||
PreferencePartition partition,
|
||||
String groupName,
|
||||
) {
|
||||
return ref.watch(
|
||||
) async {
|
||||
return await ref.watch(
|
||||
_preferenceSettingGroupsProvider(partition).selectAsync(
|
||||
(groups) =>
|
||||
groups[groupName] ?? (throw Exception('Unknown setting group')),
|
||||
@@ -104,6 +104,10 @@ class UnifiedPreferenceSettingsRepository
|
||||
Map<String, PreferenceSettingGroup>? _statelessGroups;
|
||||
|
||||
Future<void> apply() async {
|
||||
final preferenceRepository = ref.read(
|
||||
_preferenceRepositoryProvider.notifier,
|
||||
);
|
||||
|
||||
_statelessGroups = await ref.read(
|
||||
_preferenceSettingGroupsProvider(partition).future,
|
||||
);
|
||||
@@ -117,10 +121,14 @@ class UnifiedPreferenceSettingsRepository
|
||||
),
|
||||
};
|
||||
|
||||
await ref.read(_preferenceRepositoryProvider.notifier).applyPrefs(prefs);
|
||||
await preferenceRepository.applyPrefs(prefs);
|
||||
}
|
||||
|
||||
Future<void> reset() async {
|
||||
final preferenceRepository = ref.read(
|
||||
_preferenceRepositoryProvider.notifier,
|
||||
);
|
||||
|
||||
_statelessGroups = await ref.read(
|
||||
_preferenceSettingGroupsProvider(partition).future,
|
||||
);
|
||||
@@ -130,7 +138,7 @@ class UnifiedPreferenceSettingsRepository
|
||||
.flattened
|
||||
.toList();
|
||||
|
||||
await ref.read(_preferenceRepositoryProvider.notifier).resetPrefs(prefs);
|
||||
await preferenceRepository.resetPrefs(prefs);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -167,6 +175,10 @@ class PreferenceSettingsGroupRepository
|
||||
PreferenceSettingGroup? _statelessSettingGroup;
|
||||
|
||||
Future<void> apply({List<String>? filter}) async {
|
||||
final preferenceRepository = ref.read(
|
||||
_preferenceRepositoryProvider.notifier,
|
||||
);
|
||||
|
||||
_statelessSettingGroup ??= await ref.read(
|
||||
_preferenceSettingGroupProvider(partition, groupName).future,
|
||||
);
|
||||
@@ -184,10 +196,14 @@ class PreferenceSettingsGroupRepository
|
||||
.map((e) => MapEntry(e.key, e.value.value)),
|
||||
);
|
||||
|
||||
await ref.read(_preferenceRepositoryProvider.notifier).applyPrefs(prefs);
|
||||
await preferenceRepository.applyPrefs(prefs);
|
||||
}
|
||||
|
||||
Future<void> reset({List<String>? filter}) async {
|
||||
final preferenceRepository = ref.read(
|
||||
_preferenceRepositoryProvider.notifier,
|
||||
);
|
||||
|
||||
_statelessSettingGroup ??= await ref.read(
|
||||
_preferenceSettingGroupProvider(partition, groupName).future,
|
||||
);
|
||||
@@ -199,9 +215,9 @@ class PreferenceSettingsGroupRepository
|
||||
throw Exception('Preference not part of group');
|
||||
}
|
||||
|
||||
await ref
|
||||
.read(_preferenceRepositoryProvider.notifier)
|
||||
.resetPrefs(filter ?? _statelessSettingGroup!.settings.keys.toList());
|
||||
await preferenceRepository.resetPrefs(
|
||||
filter ?? _statelessSettingGroup!.settings.keys.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
+3
-3
@@ -193,7 +193,7 @@ final class _PreferenceSettingGroupProvider
|
||||
}
|
||||
|
||||
String _$_preferenceSettingGroupHash() =>
|
||||
r'64d80a37928d7e5aea7d3d567dde8ade7292cd5f';
|
||||
r'df85cf2207411a89b4c379e24989857f81d04011';
|
||||
|
||||
final class _PreferenceSettingGroupFamily extends $Family
|
||||
with
|
||||
@@ -341,7 +341,7 @@ final class UnifiedPreferenceSettingsRepositoryProvider
|
||||
}
|
||||
|
||||
String _$unifiedPreferenceSettingsRepositoryHash() =>
|
||||
r'35aa16ffa7aa1453c8331ed7470ef85a68d27178';
|
||||
r'23c0da1fdc975bbfb88b3cf82f242dbe0d50cd87';
|
||||
|
||||
final class UnifiedPreferenceSettingsRepositoryFamily extends $Family
|
||||
with
|
||||
@@ -455,7 +455,7 @@ final class PreferenceSettingsGroupRepositoryProvider
|
||||
}
|
||||
|
||||
String _$preferenceSettingsGroupRepositoryHash() =>
|
||||
r'60f416ffe1cde4d535fb5b643a80aead20836bae';
|
||||
r'05db908036ffa999886f4e9dc4429aa85f8957f9';
|
||||
|
||||
final class PreferenceSettingsGroupRepositoryFamily extends $Family
|
||||
with
|
||||
|
||||
@@ -37,7 +37,7 @@ enum SetContainerResult { failed, success, successHasProxy }
|
||||
class SelectedContainer extends _$SelectedContainer {
|
||||
Future<ContainerData?> fetchData() async {
|
||||
if (state != null) {
|
||||
return ref
|
||||
return await ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
.getContainerData(state!);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class SelectedContainer extends _$SelectedContainer {
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
.getContainerData(id);
|
||||
|
||||
if (container != null) {
|
||||
if (ref.mounted && container != null) {
|
||||
final passAuth = await authenticateContainer(container);
|
||||
if (passAuth) {
|
||||
if (container.metadata.useProxy) {
|
||||
@@ -127,7 +127,7 @@ class SelectedContainer extends _$SelectedContainer {
|
||||
.read(tabDataRepositoryProvider.notifier)
|
||||
.getContainerTabId(next);
|
||||
|
||||
if (tabContainerId != stateOrNull) {
|
||||
if (ref.mounted && tabContainerId != stateOrNull) {
|
||||
if (tabContainerId != null) {
|
||||
await setContainerId(tabContainerId);
|
||||
} else {
|
||||
|
||||
@@ -41,7 +41,7 @@ final class SelectedContainerProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$selectedContainerHash() => r'94d68a5b8f2746166ab2269afb6cd50c7c7599bf';
|
||||
String _$selectedContainerHash() => r'4754aa8ad9b43b022821a41771eb5af5e33b1cb6';
|
||||
|
||||
abstract class _$SelectedContainer extends $Notifier<String?> {
|
||||
String? build();
|
||||
|
||||
@@ -249,11 +249,13 @@ Future<String?> containerTopic(Ref ref, String containerId) async {
|
||||
),
|
||||
);
|
||||
|
||||
if (!ref.mounted) return null;
|
||||
|
||||
final topic = await ref
|
||||
.read(geckoInferenceRepositoryProvider.notifier)
|
||||
.predictDocumentTopic(titles.value);
|
||||
|
||||
if (topic.isNotEmpty) {
|
||||
if (ref.mounted && topic.isNotEmpty) {
|
||||
ref.keepAlive();
|
||||
}
|
||||
|
||||
@@ -274,7 +276,7 @@ Future<List<SuggestedContainer>?> suggestClusters(Ref ref) async {
|
||||
),
|
||||
);
|
||||
|
||||
if (unassignedTitles.value.isNotEmpty) {
|
||||
if (ref.mounted && unassignedTitles.value.isNotEmpty) {
|
||||
return await ref
|
||||
.read(geckoInferenceRepositoryProvider.notifier)
|
||||
.suggestClusters(unassignedDocumentsInput: unassignedTitles.value);
|
||||
@@ -294,6 +296,8 @@ Future<List<String>?> containerTabSuggestions(
|
||||
|
||||
final container = await ref.watch(containerDataProvider(containerId).future);
|
||||
|
||||
if (!ref.mounted) return null;
|
||||
|
||||
final assignedTitles = await ref.watch(
|
||||
containerTabsDataProvider(containerId).selectAsync(
|
||||
(tabData) => EquatableValue(
|
||||
@@ -305,6 +309,8 @@ Future<List<String>?> containerTabSuggestions(
|
||||
),
|
||||
);
|
||||
|
||||
if (!ref.mounted) return null;
|
||||
|
||||
final unassignedTitles = await ref.watch(
|
||||
containerTabsDataProvider(null).selectAsync(
|
||||
(tabData) => EquatableValue(
|
||||
@@ -316,7 +322,9 @@ Future<List<String>?> containerTabSuggestions(
|
||||
),
|
||||
);
|
||||
|
||||
if (assignedTitles.value.isNotEmpty && unassignedTitles.value.isNotEmpty) {
|
||||
if (ref.mounted &&
|
||||
assignedTitles.value.isNotEmpty &&
|
||||
unassignedTitles.value.isNotEmpty) {
|
||||
final topic =
|
||||
container?.name ??
|
||||
await ref
|
||||
@@ -325,7 +333,7 @@ Future<List<String>?> containerTabSuggestions(
|
||||
assignedTitles.value.map((tab) => tab.$2).toSet(),
|
||||
);
|
||||
|
||||
if (topic != null) {
|
||||
if (ref.mounted && topic != null) {
|
||||
final suggestedTitles = await ref
|
||||
.read(geckoInferenceRepositoryProvider.notifier)
|
||||
.suggestDocuments(
|
||||
|
||||
@@ -112,7 +112,7 @@ final class ContainerTopicProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$containerTopicHash() => r'dd2af0571a84f9cc2536af6a1079e7ee58e2a0a5';
|
||||
String _$containerTopicHash() => r'ddb306605a0e38b1d750bf4412cbd595f8f264cc';
|
||||
|
||||
final class ContainerTopicFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<String?>, String> {
|
||||
@@ -171,7 +171,7 @@ final class SuggestClustersProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$suggestClustersHash() => r'3b7da171b3596f708a8039658578251ae61655ea';
|
||||
String _$suggestClustersHash() => r'694b401ddd6ce68084f79883e67fda4b44607ef0';
|
||||
|
||||
@ProviderFor(containerTabSuggestions)
|
||||
const containerTabSuggestionsProvider = ContainerTabSuggestionsFamily._();
|
||||
@@ -230,7 +230,7 @@ final class ContainerTabSuggestionsProvider
|
||||
}
|
||||
|
||||
String _$containerTabSuggestionsHash() =>
|
||||
r'ab8e596f0c7e8562bf998c701145e48eb1e520d5';
|
||||
r'9e7e9b9d245959fcf8c87cb8822313ded801ebc0';
|
||||
|
||||
final class ContainerTabSuggestionsFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<List<String>?>, String?> {
|
||||
|
||||
Reference in New Issue
Block a user