Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix: only run sync and show option if granted ml consent

Prateek Sunalbf0e4cc8e067
diff --git a/mobile/apps/photos/lib/services/smart_albums_service.dart b/mobile/apps/photos/lib/services/smart_albums_service.dart
index 8c1c5c08cb..0c1b2856be 100644
--- a/mobile/apps/photos/lib/services/smart_albums_service.dart
+++ b/mobile/apps/photos/lib/services/smart_albums_service.dart
@@ -9,7 +9,7 @@ import "package:photos/models/api/entity/type.dart";
import "package:photos/models/collection/smart_album_config.dart";
import "package:photos/models/file/file.dart";
import "package:photos/models/local_entity_data.dart";
-import "package:photos/service_locator.dart" show entityService;
+import "package:photos/service_locator.dart" show entityService, flagService;
import "package:photos/services/collections_service.dart";
import "package:photos/services/search_service.dart";
@@ -80,8 +80,14 @@ class SmartAlbumsService {
}
Future<void> syncSmartAlbums() async {
+ final isMLEnabled = flagService.hasGrantedMLConsent;
+ if (!isMLEnabled) {
+ _logger.warning("ML is not enabled, skipping smart album sync");
+ return;
+ }
+
final cachedConfigs = await getSmartConfigs();
- final userId = Configuration.instance.getUserID();
+ final userId = Configuration.instance.getUserID()!;
for (final entry in cachedConfigs.entries) {
final collectionId = entry.key;
@@ -89,7 +95,7 @@ class SmartAlbumsService {
final collection =
CollectionsService.instance.getCollectionByID(collectionId);
- if (!(collection?.canAutoAdd(userId!) ?? false)) {
+ if (!(collection?.canAutoAdd(userId) ?? false)) {
_logger.warning(
"Deleting collection config ($collectionId) as user does not have permission",
);
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 9a999ad5d8..03c0b00625 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -529,7 +529,8 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
context.l10n.playOnTv,
icon: Icons.tv_outlined,
),
- if (widget.collection?.canAutoAdd(userId) ?? false)
+ if (flagService.hasGrantedMLConsent &&
+ (widget.collection?.canAutoAdd(userId) ?? false))
EntePopupMenuItemAsync(
(value) => (value?[widget.collection!.id]?.personIDs.isEmpty ?? true)
? S.of(context).autoAddPeople