From bf0e4cc8e067c9897eaaf14cb12c877dd66f5eea Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 29 Jul 2025 14:52:02 +0530 Subject: [PATCH] fix: only run sync and show option if granted ml consent --- .../photos/lib/services/smart_albums_service.dart | 12 +++++++++--- .../ui/viewer/gallery/gallery_app_bar_widget.dart | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) 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 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 { 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