Fix #6782. Ensure SyncThread is started
This commit is contained in:
parent
f5104c7511
commit
0b1b228524
|
@ -53,6 +53,11 @@ interface SyncService {
|
|||
*/
|
||||
fun getSyncState(): SyncState
|
||||
|
||||
/**
|
||||
* This method returns true if the sync thread is alive, i.e. started.
|
||||
*/
|
||||
fun isSyncThreadAlive(): Boolean
|
||||
|
||||
/**
|
||||
* This method allows to listen the sync state.
|
||||
* @return a [LiveData] of [SyncState].
|
||||
|
|
|
@ -73,6 +73,8 @@ internal class DefaultSyncService @Inject constructor(
|
|||
|
||||
override fun getSyncState() = getSyncThread().currentState()
|
||||
|
||||
override fun isSyncThreadAlive() = getSyncThread().isAlive
|
||||
|
||||
override fun getSyncRequestStateFlow() = syncRequestStateTracker.syncRequestState
|
||||
|
||||
override fun hasAlreadySynced(): Boolean {
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Context
|
|||
import arrow.core.Option
|
||||
import im.vector.app.ActiveSessionDataSource
|
||||
import im.vector.app.core.extensions.configureAndStart
|
||||
import im.vector.app.core.extensions.startSyncing
|
||||
import im.vector.app.core.pushers.UnifiedPushHelper
|
||||
import im.vector.app.core.services.GuardServiceStarter
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
|
@ -100,7 +101,13 @@ class ActiveSessionHolder @Inject constructor(
|
|||
}
|
||||
|
||||
suspend fun getOrInitializeSession(startSync: Boolean): Session? {
|
||||
return activeSessionReference.get() ?: sessionInitializer.tryInitialize(readCurrentSession = { activeSessionReference.get() }) { session ->
|
||||
return activeSessionReference.get()
|
||||
?.also {
|
||||
if (startSync && !it.syncService().isSyncThreadAlive()) {
|
||||
it.startSyncing(applicationContext)
|
||||
}
|
||||
}
|
||||
?: sessionInitializer.tryInitialize(readCurrentSession = { activeSessionReference.get() }) { session ->
|
||||
setActiveSession(session)
|
||||
session.configureAndStart(applicationContext, startSyncing = startSync)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue