diff --git a/vector/src/main/java/im/vector/app/core/di/ActiveSessionHolder.kt b/vector/src/main/java/im/vector/app/core/di/ActiveSessionHolder.kt index 4effc581cb..7a1d613ab9 100644 --- a/vector/src/main/java/im/vector/app/core/di/ActiveSessionHolder.kt +++ b/vector/src/main/java/im/vector/app/core/di/ActiveSessionHolder.kt @@ -27,11 +27,7 @@ import im.vector.app.features.crypto.keysrequest.KeyRequestHandler import im.vector.app.features.crypto.verification.IncomingVerificationRequestHandler import im.vector.app.features.notifications.PushRuleTriggerListener import im.vector.app.features.session.SessionListener -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.newSingleThreadContext import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withContext import org.matrix.android.sdk.api.auth.AuthenticationService import org.matrix.android.sdk.api.session.Session import timber.log.Timber @@ -106,9 +102,7 @@ class ActiveSessionHolder @Inject constructor( suspend fun getOrInitializeSession(startSync: Boolean): Session? { return activeSessionReference.get() ?: sessionInitializer.tryInitialize(readCurrentSession = { activeSessionReference.get() }) { session -> setActiveSession(session) - withContext(Dispatchers.Main) { - session.configureAndStart(applicationContext, startSyncing = startSync) - } + session.configureAndStart(applicationContext, startSyncing = startSync) } } diff --git a/vector/src/main/java/im/vector/app/core/di/SessionInitializer.kt b/vector/src/main/java/im/vector/app/core/di/SessionInitializer.kt index 1413d275f2..c800ae5118 100644 --- a/vector/src/main/java/im/vector/app/core/di/SessionInitializer.kt +++ b/vector/src/main/java/im/vector/app/core/di/SessionInitializer.kt @@ -37,7 +37,7 @@ class SessionInitializer @Inject constructor( * @param initializer callback to allow additional initialization on the Session, such as setting the in-memory Session instance. * @return the initialized Session or null when no authenticated sessions are available. */ - suspend fun tryInitialize(readCurrentSession: () -> Session?, initializer: suspend (Session) -> Unit): Session? { + suspend fun tryInitialize(readCurrentSession: () -> Session?, initializer: (Session) -> Unit): Session? { return withContext(INITIALIZER_CONTEXT) { val currentInMemorySession = readCurrentSession() when {