Pause image embedding computation when user is interacting with the app
This commit is contained in:
parent
686ae81cfa
commit
177464c203
1 changed files with 15 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue