π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] cache methods
laurenspriem78ca3937605f
diff --git a/mobile/lib/core/configuration.dart b/mobile/lib/core/configuration.dartindex e15193a5d3..b27e153e4b 100644--- a/mobile/lib/core/configuration.dart+++ b/mobile/lib/core/configuration.dart@@ -29,6 +29,7 @@ import 'package:photos/services/ignored_files_service.dart';import "package:photos/services/machine_learning/face_ml/person/person_service.dart";import 'package:photos/services/memories_service.dart';import 'package:photos/services/search_service.dart';+import "package:photos/services/smart_memories_service.dart";import 'package:photos/services/sync_service.dart';import 'package:photos/utils/crypto_util.dart';import 'package:photos/utils/file_uploader.dart';@@ -216,6 +217,7 @@ class Configuration {CollectionsService.instance.clearCache();FavoritesService.instance.clearCache();MemoriesService.instance.clearCache();+ SmartMemoriesService.instance.clearCache();SearchService.instance.clearCache();PersonService.instance.clearCache();unawaited(HomeWidgetService.instance.clearHomeWidget());diff --git a/mobile/lib/services/smart_memories_service.dart b/mobile/lib/services/smart_memories_service.dartindex 447ca8e184..c4d1f8b4fa 100644--- a/mobile/lib/services/smart_memories_service.dart+++ b/mobile/lib/services/smart_memories_service.dart@@ -4,7 +4,9 @@ import "package:flutter/material.dart";import "package:intl/intl.dart";import "package:logging/logging.dart";import "package:ml_linalg/vector.dart";+import "package:photos/core/event_bus.dart";import "package:photos/db/ml/db.dart";+import "package:photos/events/files_updated_event.dart";import "package:photos/models/base_location.dart";import "package:photos/models/file/extensions/file_props.dart";import "package:photos/models/file/file.dart";@@ -40,9 +42,28 @@ class SmartMemoriesService {if (_isInit) return;_locale = Localizations.localeOf(context);_isInit = true;++ Bus.instance.on<FilesUpdatedEvent>().where((event) {+ return event.type == EventType.deletedFromEverywhere;+ }).listen((event) {+ if (_cachedMemories == null) return;+ final generatedIDs = event.updatedFiles+ .where((element) => element.generatedID != null)+ .map((e) => e.generatedID!)+ .toSet();+ for (final memory in _cachedMemories!) {+ memory.memories+ .removeWhere((m) => generatedIDs.contains(m.file.generatedID));+ }+ });_logger.info("Smart memories service initialized");}+ void clearCache() {+ _cachedMemories = null;+ _future = null;+ }+Future<List<SmartMemory>> getMemories(int? limit) async {if (!MemoriesService.instance.showMemories) {return [];@@ -426,7 +447,8 @@ class SmartMemoriesService {DateTime.fromMicrosecondsSinceEpoch(trip.averageCreationTime()).year;final String? locationName = await _tryFindLocationName(trip.memories);- String name = "Trip in $year"; // TODO lau: extract strings for translation+ String name =+ "Trip in $year"; // TODO lau: extract strings for translationif (locationName != null) {name = "Trip to $locationName";} else if (year == currentTime.year - 1) {