mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
fix app locked on splash
This commit is contained in:
parent
4ee53ad9d0
commit
6b3d1f185d
3 changed files with 21 additions and 3 deletions
|
@ -49,7 +49,9 @@ class FdroidFcmHelper @Inject constructor(
|
|||
|
||||
override fun onEnterForeground(activeSessionHolder: ActiveSessionHolder) {
|
||||
// try to stop all regardless of background mode
|
||||
activeSessionHolder.getSafeActiveSession()?.syncService()?.stopAnyBackgroundSync()
|
||||
activeSessionHolder.getSafeActiveSessionAsync {
|
||||
it?.syncService()?.stopAnyBackgroundSync()
|
||||
}
|
||||
AlarmSyncBroadcastReceiver.cancelAlarm(context)
|
||||
}
|
||||
|
||||
|
|
|
@ -190,9 +190,12 @@ class VectorApplication :
|
|||
override fun onResume(owner: LifecycleOwner) {
|
||||
Timber.i("App entered foreground")
|
||||
fcmHelper.onEnterForeground(activeSessionHolder)
|
||||
activeSessionHolder.getSafeActiveSession()?.also {
|
||||
it.syncService().stopAnyBackgroundSync()
|
||||
activeSessionHolder.getSafeActiveSessionAsync {
|
||||
it?.syncService()?.stopAnyBackgroundSync()
|
||||
}
|
||||
// activeSessionHolder.getSafeActiveSession()?.also {
|
||||
// it.syncService().stopAnyBackgroundSync()
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onPause(owner: LifecycleOwner) {
|
||||
|
|
|
@ -18,6 +18,7 @@ package im.vector.app.core.di
|
|||
|
||||
import android.content.Context
|
||||
import im.vector.app.ActiveSessionDataSource
|
||||
import im.vector.app.core.dispatchers.CoroutineDispatchers
|
||||
import im.vector.app.core.pushers.UnregisterUnifiedPushUseCase
|
||||
import im.vector.app.core.services.GuardServiceStarter
|
||||
import im.vector.app.core.session.ConfigureAndStartSessionUseCase
|
||||
|
@ -26,7 +27,10 @@ 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.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
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 org.matrix.android.sdk.api.util.Optional
|
||||
|
@ -51,6 +55,8 @@ class ActiveSessionHolder @Inject constructor(
|
|||
private val authenticationService: AuthenticationService,
|
||||
private val configureAndStartSessionUseCase: ConfigureAndStartSessionUseCase,
|
||||
private val unregisterUnifiedPushUseCase: UnregisterUnifiedPushUseCase,
|
||||
private val applicationCoroutineScope: CoroutineScope,
|
||||
private val coroutineDispatchers: CoroutineDispatchers,
|
||||
) {
|
||||
|
||||
private var activeSessionReference: AtomicReference<Session?> = AtomicReference()
|
||||
|
@ -96,6 +102,13 @@ class ActiveSessionHolder @Inject constructor(
|
|||
return runBlocking { getOrInitializeSession() }
|
||||
}
|
||||
|
||||
fun getSafeActiveSessionAsync(withSession: ((Session?) -> Unit)) {
|
||||
applicationCoroutineScope.launch(coroutineDispatchers.io) {
|
||||
val session = getOrInitializeSession()
|
||||
withSession(session)
|
||||
}
|
||||
}
|
||||
|
||||
fun getActiveSession(): Session {
|
||||
return getSafeActiveSession()
|
||||
?: throw IllegalStateException("You should authenticate before using this")
|
||||
|
|
Loading…
Reference in a new issue