mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-22 15:50:51 +01:00
avoiding unneeded main context switch
This commit is contained in:
parent
410a7b525f
commit
6b754f3e03
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user