π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Time as parameter
laurenspriem7cecf848411b
diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dartindex 5f491159fb..8080dd61b1 100644--- a/mobile/lib/services/memories_cache_service.dart+++ b/mobile/lib/services/memories_cache_service.dart@@ -131,7 +131,12 @@ class MemoriesCacheService {final EnteWatch? w =kDebugMode ? EnteWatch("MemoriesCacheService") : null;w?.start();- final memories = await SmartMemoriesService.instance.calcMemories();+ // calculate memories for this period and for the next period+ final now = DateTime.now();+ final next = now.add(_kUpdateFrequency);+ final List<SmartMemory> memories = [];+ memories.addAll(await SmartMemoriesService.instance.calcMemories(now));+ memories.addAll(await SmartMemoriesService.instance.calcMemories(next));w?.log("calculated new memories");final oldCache = await _readCacheFromDisk();w?.log("gotten old cache");diff --git a/mobile/lib/services/smart_memories_service.dart b/mobile/lib/services/smart_memories_service.dartindex 6e2f8ab771..1597d7f5b5 100644--- a/mobile/lib/services/smart_memories_service.dart+++ b/mobile/lib/services/smart_memories_service.dart@@ -70,7 +70,7 @@ class SmartMemoriesService {}// One general method to get all memories, which calls on internal methods for each separate memory type- Future<List<SmartMemory>> calcMemories() async {+ Future<List<SmartMemory>> calcMemories(DateTime now) async {try {await init();final List<SmartMemory> memories = [];@@ -80,19 +80,19 @@ class SmartMemoriesService {_seenTimes = await _memoriesDB.getSeenTimes();_logger.finest("All files length: ${allFiles.length}");- final peopleMemories = await _getPeopleResults(allFiles, null);+ final peopleMemories = await _getPeopleResults(allFiles, now);_deductUsedMemories(allFiles, peopleMemories);memories.addAll(peopleMemories);_logger.finest("All files length: ${allFiles.length}");// Trip memories- final tripMemories = await _getTripsResults(allFiles, null);+ final tripMemories = await _getTripsResults(allFiles, now);_deductUsedMemories(allFiles, tripMemories);memories.addAll(tripMemories);_logger.finest("All files length: ${allFiles.length}");// Time memories- final timeMemories = await _onThisDayOrWeekResults(allFiles, null);+ final timeMemories = await _onThisDayOrWeekResults(allFiles, now);_deductUsedMemories(allFiles, timeMemories);memories.addAll(timeMemories);_logger.finest("All files length: ${allFiles.length}");@@ -122,7 +122,7 @@ class SmartMemoriesService {Future<List<PeopleMemory>> _getPeopleResults(Iterable<EnteFile> allFiles,- int? limit, // TODO: lau: implement limit+ DateTime currentTime,) async {final List<PeopleMemory> memoryResults = [];if (allFiles.isEmpty) return [];@@ -132,7 +132,6 @@ class SmartMemoriesService {allFileIdsToFile[file.uploadedFileID!] = file;}}- final currentTime = DateTime.now().toLocal();// Get ordered list of important people (all named, from most to least files)final persons = await PersonService.instance.getPersons();@@ -356,13 +355,12 @@ class SmartMemoriesService {Future<List<TripMemory>> _getTripsResults(Iterable<EnteFile> allFiles,- int? limit,+ DateTime currentTime,) async {final List<TripMemory> memoryResults = [];final Iterable<LocalEntity<LocationTag>> locationTagEntities =(await locationService.getLocationTags());if (allFiles.isEmpty) return [];- final currentTime = DateTime.now().toLocal();final currentMonth = currentTime.month;final cutOffTime = currentTime.subtract(const Duration(days: 365));@@ -684,9 +682,6 @@ class SmartMemoriesService {name: name,),);- if (limit != null && memoryResults.length >= limit) {- return memoryResults;- }}}// Otherwise, if no trips happened in the current month,@@ -738,12 +733,11 @@ class SmartMemoriesService {Future<List<TimeMemory>> _onThisDayOrWeekResults(Iterable<EnteFile> allFiles,- int? limit,+ DateTime currentTime,) async {final List<TimeMemory> memoryResult = [];if (allFiles.isEmpty) return [];- final currentTime = DateTime.now().toLocal();final currentDayMonth = currentTime.month * 100 + currentTime.day;final currentWeek = _getWeekNumber(currentTime);final currentMonth = currentTime.month;@@ -814,8 +808,6 @@ class SmartMemoriesService {);}}-- if (limit != null && memoryResult.length >= limit) return memoryResult;}// process to find significant weeks (only if there are no significant days)@@ -876,8 +868,6 @@ class SmartMemoriesService {}}- if (limit != null && memoryResult.length >= limit) return memoryResult;-// process to find fillers (months)const wantedMemories = 3;final neededMemories = wantedMemories - memoryResult.length;