Merge pull request #387 from vector-im/feature/fix_sync_state

Fix sync state progress bar
This commit is contained in:
Benoit Marty 2019-07-18 10:57:46 +02:00 committed by GitHub
commit 64bee91f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)