From ea655474ae52af07650832650438c187ce81b93f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 7 Apr 2022 10:36:53 +0200 Subject: [PATCH] Do not cancel current sync request when going to background #5621 Incremental sync can be long and it requires the user to wait for the treatment to end, else all is restarted from the beginning each time the user moves the app to foreground. --- changelog.d/5719.feature | 1 + .../android/sdk/internal/session/sync/job/SyncThread.kt | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog.d/5719.feature diff --git a/changelog.d/5719.feature b/changelog.d/5719.feature new file mode 100644 index 00000000000..7561dfd82fd --- /dev/null +++ b/changelog.d/5719.feature @@ -0,0 +1 @@ +Do not cancel the current incremental sync request and treatment when the app goes to background \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt index 2460720adc6..204c26a8d60 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt @@ -107,7 +107,11 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, Timber.tag(loggerTag.value).d("Pause sync...") isStarted = false retryNoNetworkTask?.cancel() - syncScope.coroutineContext.cancelChildren() + // Do not cancel the current incremental sync. + // Incremental sync can be long and it requires the user to wait for the treatment to end, + // else all is restarted from the beginning each time the user moves the app to foreground. + Timber.tag(loggerTag.value).d("Pause sync... Not cancelling incremental sync") + // syncScope.coroutineContext.cancelChildren() } }