Skip to content

armgit / ente

Public Imported from GitHub
0

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

Pause image embedding computation when user is interacting with the app

vishnukvmd177464c203cb
diff --git a/lib/services/semantic_search/semantic_search_service.dart b/lib/services/semantic_search/semantic_search_service.dart
index 62d20da175..8699b0e4ec 100644
--- a/lib/services/semantic_search/semantic_search_service.dart
+++ b/lib/services/semantic_search/semantic_search_service.dart
@@ -49,12 +49,21 @@ class SemanticSearchService {
Future<List<EnteFile>>? _ongoingRequest;
List<Embedding> _cachedEmbeddings = <Embedding>[];
PendingQuery? _nextQuery;
+ Completer<void> _userInteraction = Completer<void>();
get hasInitialized => _hasInitialized;
- void resumeIndexing() {}
+ void resumeIndexing() {
+ _logger.info("Resuming indexing");
+ _userInteraction.complete();
+ }
- void pauseIndexing() {}
+ void pauseIndexing() {
+ if (_userInteraction.isCompleted) {
+ _logger.info("Pausing indexing");
+ _userInteraction = Completer<void>();
+ }
+ }
Future<void> init({bool shouldSyncImmediately = false}) async {
if (!LocalSettings.instance.hasEnabledMagicSearch()) {
@@ -283,6 +292,10 @@ class SemanticSearchService {
if (!_frameworkInitialization.isCompleted) {
return;
}
+ if (!_userInteraction.isCompleted) {
+ _logger.info("Waiting for user interactions to stop...");
+ await _userInteraction.future;
+ }
try {
final thumbnail = await getThumbnailForUploadedFile(file);
if (thumbnail == null) {