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