Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Fix ML consent logic

laurenspriem602e820442e5
diff --git a/mobile/lib/ui/settings/ml/machine_learning_settings_page.dart b/mobile/lib/ui/settings/ml/machine_learning_settings_page.dart
index 707c9b67fd..6604a7ef59 100644
--- a/mobile/lib/ui/settings/ml/machine_learning_settings_page.dart
+++ b/mobile/lib/ui/settings/ml/machine_learning_settings_page.dart
@@ -214,16 +214,7 @@ class _MachineLearningSettingsPageState
Future<void> toggleMlConsent() async {
final oldMlConsent = userRemoteFlagService
.getCachedBoolValue(UserRemoteFlagService.mlEnabled);
- final mlConsent = !oldMlConsent;
- await userRemoteFlagService.setBoolValue(
- UserRemoteFlagService.mlEnabled,
- mlConsent,
- );
- if (!mlConsent) {
- MLService.instance.pauseIndexingAndClustering();
- unawaited(
- MLIndexingIsolate.instance.cleanupLocalIndexingModels(),
- );
+ if (!oldMlConsent) { // Go to consent page first if not enabled
final result = await Navigator.push(
context,
MaterialPageRoute(
@@ -235,6 +226,17 @@ class _MachineLearningSettingsPageState
if (result == null || result == false) {
return;
}
+ }
+ final mlConsent = !oldMlConsent;
+ await userRemoteFlagService.setBoolValue(
+ UserRemoteFlagService.mlEnabled,
+ mlConsent,
+ );
+ if (!mlConsent) {
+ MLService.instance.pauseIndexingAndClustering();
+ unawaited(
+ MLIndexingIsolate.instance.cleanupLocalIndexingModels(),
+ );
} else {
await MLService.instance.init();
await SemanticSearchService.instance.init();