From 7708c38ef515cc30260e01e7d686b72d6f20572c Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Sat, 17 Feb 2024 15:32:53 +0530 Subject: [PATCH] Do not block on user interactions in the background --- lib/main.dart | 2 +- .../semantic_search/semantic_search_service.dart | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 8e553280b..ce1d567d9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -193,7 +193,7 @@ Future _init(bool isBackground, {String via = ''}) async { }); } unawaited(FeatureFlagService.instance.init()); - unawaited(SemanticSearchService.instance.init()); + unawaited(SemanticSearchService.instance.init(isInBackground: isBackground)); // Can not including existing tf/ml binaries as they are not being built // from source. // See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/12671#note_1294346819 diff --git a/lib/services/semantic_search/semantic_search_service.dart b/lib/services/semantic_search/semantic_search_service.dart index 16408db30..51291e2cf 100644 --- a/lib/services/semantic_search/semantic_search_service.dart +++ b/lib/services/semantic_search/semantic_search_service.dart @@ -66,7 +66,10 @@ class SemanticSearchService { } } - Future init({bool shouldSyncImmediately = false}) async { + Future init({ + bool shouldSyncImmediately = false, + bool isInBackground = false, + }) async { if (!LocalSettings.instance.hasEnabledMagicSearch()) { return; } @@ -111,6 +114,10 @@ class SemanticSearchService { if (shouldSyncImmediately) { unawaited(sync()); } + if (isInBackground) { + // Do not block on user interactions + resumeIndexing(); + } } Future release() async {