From 7e3b300130055c810385c7439ddd18bda0712776 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 17 Jul 2019 19:45:35 +0200 Subject: [PATCH] Fix sync state progress bar --- .../android/internal/session/sync/job/SyncThread.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt index 65c79bd8..6a54ad33 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt @@ -54,8 +54,9 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, updateStateTo(SyncState.IDLE) } - fun setInitialForeground(initialForground : Boolean) { - updateStateTo(if (initialForground) SyncState.IDLE else SyncState.PAUSED) + fun setInitialForeground(initialForeground: Boolean) { + val newState = if (initialForeground) SyncState.IDLE else SyncState.PAUSED + updateStateTo(newState) } fun restart() = synchronized(lock) { @@ -96,7 +97,9 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, lock.wait() } } else { - updateStateTo(SyncState.RUNNING(catchingUp = true)) + if (state !is SyncState.RUNNING) { + updateStateTo(SyncState.RUNNING(catchingUp = true)) + } Timber.v("[$this] Execute sync request with timeout $DEFAULT_LONG_POOL_TIMEOUT") val latch = CountDownLatch(1) val params = SyncTask.Params(DEFAULT_LONG_POOL_TIMEOUT)