π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] clean up stale lone cluster timelines after person creation
Priyanshu Dangare0ea7b7ab7468
diff --git a/mobile/apps/photos/lib/events/people_changed_event.dart b/mobile/apps/photos/lib/events/people_changed_event.dartindex d421aa8936..4d6c9e5bdb 100644--- a/mobile/apps/photos/lib/events/people_changed_event.dart+++ b/mobile/apps/photos/lib/events/people_changed_event.dart@@ -29,4 +29,5 @@ enum PeopleEventType {saveOrEditPerson,addedClusterToPerson,reviewedSuggestion,+ automaticallyMergedClustersIntoPerson,}diff --git a/mobile/apps/photos/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart b/mobile/apps/photos/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dartindex 41cb4c3174..020b53d5b9 100644--- a/mobile/apps/photos/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart+++ b/mobile/apps/photos/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart@@ -1273,7 +1273,12 @@ class ClusterFeedbackService<T> {}if (firePeopleChangedEvent) {- Bus.instance.fire(PeopleChangedEvent());+ Bus.instance.fire(+ PeopleChangedEvent(+ type: PeopleEventType.automaticallyMergedClustersIntoPerson,+ person: await PersonService.instance.getPerson(p.remoteID),+ ),+ );}return true;diff --git a/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart b/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dartindex ebef978883..7858db3a8c 100644--- a/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart+++ b/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart@@ -292,10 +292,17 @@ class MemoryLaneService {if (!isFeatureEnabled) {return;}- if (event.type == PeopleEventType.syncDone) {- return;+ final person = event.person;+ if (person != null) {+ final clusters = person.data.assigned.map((cluster) => cluster.id);+ unawaited(_cleanupAssignedClusterTimelines(clusters));+ }+ if (event.type == PeopleEventType.addedClusterToPerson) {+ unawaited(_cleanupAssignedClusterTimelines([event.source]));+ }+ if (event.type != PeopleEventType.syncDone) {+ unawaited(_processPeopleChange(event));}- unawaited(_processPeopleChange(event));}Future<void> _processPeopleChange(PeopleChangedEvent event) async {@@ -819,6 +826,28 @@ class MemoryLaneService {}readyPersonIds.value = current;}++ Future<void> _cleanupAssignedClusterTimelines(+ Iterable<String> clusters,+ ) async {+ try {+ if (clusters.isEmpty) {+ return;+ }+ final cache = await _cacheService.getCache();+ for (final timeline in cache.allTimelines) {+ if (!timeline.isCluster) {+ continue;+ }+ if (!clusters.contains(timeline.personId)) {+ continue;+ }+ await _removeTimeline(timeline.personId);+ }+ } catch (e, s) {+ _logger.severe("_cleanupAssignedClusterTimelines failed", e, s);+ }+ }}class _TimelineFaceData {