Fix login state
This commit is contained in:
parent
21228c23b2
commit
fec43424df
2 changed files with 3 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ import io.element.android.x.matrix.util.logError
|
|||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.rustcomponents.sdk.AuthenticationService
|
||||
import org.matrix.rustcomponents.sdk.Client
|
||||
|
|
@ -26,13 +27,11 @@ class Matrix(
|
|||
private val baseFolder = File(context.filesDir, "matrix")
|
||||
private val sessionStore = SessionStore(context)
|
||||
private val matrixClient = MutableStateFlow<Optional<MatrixClient>>(Optional.empty())
|
||||
private val isLoggedIn = MutableStateFlow(false)
|
||||
|
||||
init {
|
||||
sessionStore.isLoggedIn()
|
||||
.distinctUntilChanged()
|
||||
.onEach { isLoggedIn ->
|
||||
this.isLoggedIn.value = isLoggedIn
|
||||
if (!isLoggedIn) {
|
||||
matrixClient.value = Optional.empty()
|
||||
}
|
||||
|
|
@ -41,7 +40,7 @@ class Matrix(
|
|||
}
|
||||
|
||||
fun isLoggedIn(): Flow<Boolean> {
|
||||
return isLoggedIn
|
||||
return sessionStore.isLoggedIn()
|
||||
}
|
||||
|
||||
fun client(): Flow<Optional<MatrixClient>> {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package io.element.android.x.matrix
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
|
||||
|
||||
object MatrixInstance {
|
||||
|
|
@ -11,6 +10,7 @@ object MatrixInstance {
|
|||
private lateinit var instance: Matrix
|
||||
|
||||
fun init(context: Context, coroutineScope: CoroutineScope) {
|
||||
//setupTracing("warn,matrix_sdk::sliding_sync=info")
|
||||
instance = Matrix(coroutineScope, context)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue