Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix background smart album person refresh

laurenspriem7058a03a2e48
diff --git a/mobile/apps/photos/changes/background-smart-album-person-sync.md b/mobile/apps/photos/changes/background-smart-album-person-sync.md
new file mode 100644
index 0000000000..8d2418136b
--- /dev/null
+++ b/mobile/apps/photos/changes/background-smart-album-person-sync.md
@@ -0,0 +1 @@
+- Fixed background album auto-add missing updated person assignments when local indexing is disabled.
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dart
index e26132a8cd..5637836155 100644
--- a/mobile/apps/photos/lib/main.dart
+++ b/mobile/apps/photos/lib/main.dart
@@ -367,17 +367,25 @@ Future<void> _runMinimally(
final locale = await getLocale();
await initializeDateFormatting(locale?.languageCode ?? "en");
_logger.info("[BG TASK] home widget sync");
- if (!isLocalGalleryMode &&
- hasGrantedMLConsent &&
- localSettings.isMLLocalIndexingEnabled) {
- PersonService.init(entityService, MLDataDB.instance, prefs);
- _logger.info(
- "[BG TASK] person service initialized for memories recompute",
- );
- // The DiffSyncCompleteEvent fired during _sync predates PersonService
- // init in this isolate, so sync explicitly before consuming person data.
+ if (!isLocalGalleryMode && hasGrantedMLConsent) {
try {
- await PersonService.instance.sync();
+ final userID = Configuration.instance.getUserID();
+ if (localSettings.isMLLocalIndexingEnabled ||
+ (await smartAlbumsService.getSmartConfigs()).values.any(
+ (config) =>
+ config.personIDs.isNotEmpty &&
+ userID != null &&
+ (CollectionsService.instance
+ .getCollectionByID(config.collectionId)
+ ?.canAutoAdd(userID) ??
+ false),
+ )) {
+ PersonService.init(entityService, MLDataDB.instance, prefs);
+ _logger.info(
+ "[BG TASK] person service initialized for background sync",
+ );
+ await PersonService.instance.sync();
+ }
} catch (e, s) {
_logger.warning("[BG TASK] person sync failed", e, s);
}