Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] purge cluster timelines if not in freshly computed top N set

aspizu58c1a5852d06
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.dart
index 10243718c0..a903897b4b 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
@@ -122,23 +122,18 @@ class MemoryLaneService {
assigned.add(cluster.id);
}
}
- _topNClusters = {};
+ _topNClusters = await _mlDataDB.getClustersForMemoryLane(assigned);
final cache = await _cacheService.getCache();
final List<Future<void>> tasks = [];
for (final timeline in cache.allTimelines) {
- if (timeline.isCluster) {
- if (assigned.contains(timeline.personId)) {
- tasks.add(_cacheService.removeTimeline(timeline.personId));
- tasks.add(_cacheService.removeComputeLogEntry(timeline.personId));
- } else {
- _topNClusters.add(timeline.personId);
- }
+ if (timeline.isCluster && !_topNClusters.contains(timeline.personId)) {
+ tasks.add(_cacheService.removeTimeline(timeline.personId));
+ tasks.add(_cacheService.removeComputeLogEntry(timeline.personId));
}
}
if (tasks.isNotEmpty) {
unawaited(Future.wait(tasks).then((_) => _refreshReadyPersonIds()));
}
- _topNClusters.addAll(await _mlDataDB.getClustersForMemoryLane(assigned));
for (final cluster in _topNClusters) {
schedulePersonRecompute(cluster, isCluster: true, force: force);
}