Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Compute trigger

laurensprieme80774707986
diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dart
index e7afaf56e5..0961b50e4c 100644
--- a/mobile/lib/services/machine_learning/ml_service.dart
+++ b/mobile/lib/services/machine_learning/ml_service.dart
@@ -152,8 +152,8 @@ class MLService {
if (_mlControllerStatus == true) {
// refresh discover section
magicCacheService.updateCache().ignore();
- // refresh memories section
- memoriesCacheService.updateCache().ignore();
+ // refresh memories section (only runs if forced is true)
+ memoriesCacheService.updateCache(forced: force).ignore();
}
} catch (e, s) {
_logger.severe("runAllML failed", e, s);
diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dart
index 4b63484642..4d6e0da42c 100644
--- a/mobile/lib/services/memories_cache_service.dart
+++ b/mobile/lib/services/memories_cache_service.dart
@@ -20,6 +20,7 @@ import "package:shared_preferences/shared_preferences.dart";
class MemoriesCacheService {
static const _lastMemoriesCacheUpdateTimeKey = "lastMemoriesCacheUpdateTime";
static const _showAnyMemoryKey = "memories.enabled";
+ static const _shouldUpdateCacheKey = "memories.shouldUpdateCache";
/// Delay is for cache update to be done not during app init, during which a
/// lot of other things are happening.
@@ -88,8 +89,9 @@ class MemoriesCacheService {
if (!enableSmartMemories) {
return;
}
+ _shouldUpdate = _prefs.getBool(_shouldUpdateCacheKey) ?? _shouldUpdate;
if (_timeToUpdateCache()) {
- _shouldUpdate = true;
+ queueUpdateCache();
}
}
@@ -125,6 +127,12 @@ class MemoriesCacheService {
void queueUpdateCache() {
_shouldUpdate = true;
+ unawaited(_prefs.setBool(_shouldUpdateCacheKey, true));
+ }
+
+ void _cacheUpdated() {
+ _shouldUpdate = false;
+ unawaited(_prefs.setBool(_shouldUpdateCacheKey, false));
}
Future<void> updateCache({bool forced = false}) async {
@@ -185,7 +193,7 @@ class MemoriesCacheService {
w?.log("cacheWritten");
await _resetLastMemoriesCacheUpdateTime();
w?.logAndReset('done');
- _shouldUpdate = false;
+ _cacheUpdated();
} catch (e, s) {
_logger.info("Error updating memories cache", e, s);
} finally {