Skip to content

armgit / ente

Public Imported from GitHub
0

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

Lower local indexing threshold in offline mode

laurenspriemf07f3480e29d
diff --git a/mobile/apps/photos/lib/ui/components/banners/ml_progress_banner.dart b/mobile/apps/photos/lib/ui/components/banners/ml_progress_banner.dart
index c3b2fb13bf..23cac06e32 100644
--- a/mobile/apps/photos/lib/ui/components/banners/ml_progress_banner.dart
+++ b/mobile/apps/photos/lib/ui/components/banners/ml_progress_banner.dart
@@ -90,6 +90,7 @@ class _MLProgressBannerState extends State<MLProgressBanner> {
!_dismissed &&
hasGrantedMLConsent &&
!localSettings.isMLProgressBannerDismissed &&
+ !(isOfflineMode && !localSettings.isMLLocalIndexingEnabled) &&
!_indexingComplete;
Future<void> _fetchStatus() async {
@@ -123,6 +124,9 @@ class _MLProgressBannerState extends State<MLProgressBanner> {
if (localSettings.isMLProgressBannerDismissed) {
return const SizedBox.shrink();
}
+ if (isOfflineMode && !localSettings.isMLLocalIndexingEnabled) {
+ return const SizedBox.shrink();
+ }
final status = _indexStatus;
if (status == null) return const SizedBox.shrink();
diff --git a/mobile/apps/photos/lib/utils/local_settings.dart b/mobile/apps/photos/lib/utils/local_settings.dart
index ad94ed39fd..3240f94f8b 100644
--- a/mobile/apps/photos/lib/utils/local_settings.dart
+++ b/mobile/apps/photos/lib/utils/local_settings.dart
@@ -256,11 +256,17 @@ class LocalSettings {
await _setFlag(OfflineFlag.mapEnabled, value);
}
+ String get _mlLocalIndexingKey => appMode == AppMode.offline
+ ? _kOfflineMLLocalIndexingEnabled
+ : _kisMLLocalIndexingEnabled;
+
+ bool get _defaultMLLocalIndexingEnabled => appMode == AppMode.offline
+ ? enoughRamForOfflineLocalIndexing
+ : enoughRamForLocalIndexing;
+
bool get isMLLocalIndexingEnabled {
- final key = appMode == AppMode.offline
- ? _kOfflineMLLocalIndexingEnabled
- : _kisMLLocalIndexingEnabled;
- return _prefs.getBool(key) ?? enoughRamForLocalIndexing;
+ return _prefs.getBool(_mlLocalIndexingKey) ??
+ _defaultMLLocalIndexingEnabled;
}
bool get isSmartMemoriesEnabled =>
@@ -333,11 +339,9 @@ class LocalSettings {
/// toggleFaceIndexing toggles the face indexing setting and returns the new value
Future<bool> toggleLocalMLIndexing() async {
- final key = appMode == AppMode.offline
- ? _kOfflineMLLocalIndexingEnabled
- : _kisMLLocalIndexingEnabled;
- final nextValue = !(_prefs.getBool(key) ?? enoughRamForLocalIndexing);
- await _prefs.setBool(key, nextValue);
+ final nextValue = !(_prefs.getBool(_mlLocalIndexingKey) ??
+ _defaultMLLocalIndexingEnabled);
+ await _prefs.setBool(_mlLocalIndexingKey, nextValue);
return nextValue;
}
diff --git a/mobile/apps/photos/lib/utils/ram_check_util.dart b/mobile/apps/photos/lib/utils/ram_check_util.dart
index f6f230fb84..aff9caf12b 100644
--- a/mobile/apps/photos/lib/utils/ram_check_util.dart
+++ b/mobile/apps/photos/lib/utils/ram_check_util.dart
@@ -6,6 +6,9 @@ int? deviceTotalRAM;
bool get enoughRamForLocalIndexing =>
deviceTotalRAM == null || deviceTotalRAM! >= 5 * 1024;
+bool get enoughRamForOfflineLocalIndexing =>
+ deviceTotalRAM == null || deviceTotalRAM! > 3 * 1024;
+
/// Return the total amount of RAM in the device in MB
Future<int?> checkDeviceTotalRAM() async {
deviceTotalRAM ??= await SystemInfoPlus.physicalMemory; // returns in MB