Prevent foreground backfill from running when the app is active (#7932)

* Prevent foreground backfill from running when the app is active

This should be a background task, since it can severely degrade performance if the app is in use while it runs.

The worker won't run any more if the app is in foreground and will stop running if it was in background and now it's in foreground.

* Fix return inside `withTimeout`

Co-authored-by: Benoit Marty <benoitm@element.io>

* Remove initial delay: it shouldn't be necessary if the foreground state of the app is checked when the worker starts

Instead, if the app was in foreground, cancel the work and retry in 5 minutes.

---------

Co-authored-by: Benoit Marty <benoitm@element.io>
This commit is contained in:
Jorge Martin Espinosa
2026-10-15 16:09:09 +02:00
committed by GitHub
parent 8689961f0d
commit 287001f9aa
6 changed files with 109 additions and 5 deletions
+1
View File
@@ -82,6 +82,7 @@ dependencies {
implementation(variantOf(libs.jna) { artifactType("aar") })
implementation(libs.androidx.datastore.preferences)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.androidx.lifecycle.process)
testCommonDependencies(libs)
testImplementation(projects.features.enterprise.test)