Do not block on user interactions in the background (#1726)
This commit is contained in:
commit
ad14269af1
3 changed files with 13 additions and 6 deletions
|
@ -85,10 +85,10 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
|||
if (Platform.isAndroid || kDebugMode) {
|
||||
_userInteractionTimer = Timer(timeout, () {
|
||||
debugPrint("user is not interacting with the app");
|
||||
SemanticSearchService.instance.resumeIndexing();
|
||||
SemanticSearchService.instance.startIndexing();
|
||||
});
|
||||
} else {
|
||||
SemanticSearchService.instance.resumeIndexing();
|
||||
SemanticSearchService.instance.startIndexing();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ Future<void> _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
|
||||
|
|
|
@ -54,8 +54,8 @@ class SemanticSearchService {
|
|||
|
||||
get hasInitialized => _hasInitialized;
|
||||
|
||||
void resumeIndexing() {
|
||||
_logger.info("Resuming indexing");
|
||||
void startIndexing() {
|
||||
_logger.info("Start indexing");
|
||||
_userInteraction.complete();
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,10 @@ class SemanticSearchService {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> init({bool shouldSyncImmediately = false}) async {
|
||||
Future<void> 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
|
||||
startIndexing();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> release() async {
|
||||
|
|
Loading…
Add table
Reference in a new issue