From 03d6aa8cd390944bcad1c544dd1b65d50c1af9cd 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, 5 insertions(+), 2 deletions(-) create mode 100644 changelog.d/5719.feature diff --git a/changelog.d/5719.feature b/changelog.d/5719.feature new file mode 100644 index 0000000000..7561dfd82f --- /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 2460720adc..50049dacab 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 @@ -104,10 +104,12 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, fun pause() = synchronized(lock) { if (isStarted) { - Timber.tag(loggerTag.value).d("Pause sync...") + Timber.tag(loggerTag.value).d("Pause sync... Not cancelling incremental 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. } }