π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Remove singleton pattern
laurenspriem09e65e8d003b
diff --git a/mobile/lib/service_locator.dart b/mobile/lib/service_locator.dartindex 037e7c9a7e..599d7c04eb 100644--- a/mobile/lib/service_locator.dart+++ b/mobile/lib/service_locator.dart@@ -11,6 +11,7 @@ import "package:photos/services/machine_learning/face_ml/face_recognition_servicimport "package:photos/services/machine_learning/machine_learning_controller.dart";import "package:photos/services/magic_cache_service.dart";import "package:photos/services/memories_cache_service.dart";+import "package:photos/services/smart_memories_service.dart";import "package:photos/services/storage_bonus_service.dart";import "package:photos/services/trash_sync_service.dart";import "package:photos/services/update_service.dart";@@ -127,6 +128,12 @@ MemoriesCacheService get memoriesCacheService {return _memoriesCacheService!;}+SmartMemoriesService? _smartMemoriesService;+SmartMemoriesService get smartMemoriesService {+ _smartMemoriesService ??= SmartMemoriesService();+ return _smartMemoriesService!;+}+BillingService? _billingService;BillingService get billingService {_billingService ??= BillingService(diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dartindex 40c9d8ea72..6745f314d3 100644--- a/mobile/lib/services/memories_cache_service.dart+++ b/mobile/lib/services/memories_cache_service.dart@@ -15,7 +15,6 @@ import "package:photos/models/smart_memory.dart";import "package:photos/service_locator.dart";import "package:photos/services/location_service.dart";import "package:photos/services/search_service.dart";-import "package:photos/services/smart_memories_service.dart";import "package:shared_preferences/shared_preferences.dart";class MemoriesCacheService {@@ -137,9 +136,9 @@ class MemoriesCacheService {// calculate memories for this period and for the next periodfinal now = DateTime.now();final next = now.add(kMemoriesUpdateFrequency);- final nowMemories = await SmartMemoriesService.instance.calcMemories(now);+ final nowMemories = await smartMemoriesService.calcMemories(now);final nextMemories =- await SmartMemoriesService.instance.calcMemories(next);+ await smartMemoriesService.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 e5eb142b7d..f5e4375a0d 100644--- a/mobile/lib/services/smart_memories_service.dart+++ b/mobile/lib/services/smart_memories_service.dart@@ -48,10 +48,7 @@ class SmartMemoriesService {static const _clipSimilarImageThreshold = 0.75;static const _clipActivityQueryThreshold = 0.25;- // Singleton pattern- SmartMemoriesService._privateConstructor();- static final instance = SmartMemoriesService._privateConstructor();- factory SmartMemoriesService() => instance;+ SmartMemoriesService();Future<void> init() async {if (_isInit) return;