mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Fix login state
This commit is contained in:
@@ -7,6 +7,7 @@ import io.element.android.x.matrix.util.logError
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.rustcomponents.sdk.AuthenticationService
|
import org.matrix.rustcomponents.sdk.AuthenticationService
|
||||||
import org.matrix.rustcomponents.sdk.Client
|
import org.matrix.rustcomponents.sdk.Client
|
||||||
@@ -26,13 +27,11 @@ class Matrix(
|
|||||||
private val baseFolder = File(context.filesDir, "matrix")
|
private val baseFolder = File(context.filesDir, "matrix")
|
||||||
private val sessionStore = SessionStore(context)
|
private val sessionStore = SessionStore(context)
|
||||||
private val matrixClient = MutableStateFlow<Optional<MatrixClient>>(Optional.empty())
|
private val matrixClient = MutableStateFlow<Optional<MatrixClient>>(Optional.empty())
|
||||||
private val isLoggedIn = MutableStateFlow(false)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
sessionStore.isLoggedIn()
|
sessionStore.isLoggedIn()
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.onEach { isLoggedIn ->
|
.onEach { isLoggedIn ->
|
||||||
this.isLoggedIn.value = isLoggedIn
|
|
||||||
if (!isLoggedIn) {
|
if (!isLoggedIn) {
|
||||||
matrixClient.value = Optional.empty()
|
matrixClient.value = Optional.empty()
|
||||||
}
|
}
|
||||||
@@ -41,7 +40,7 @@ class Matrix(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isLoggedIn(): Flow<Boolean> {
|
fun isLoggedIn(): Flow<Boolean> {
|
||||||
return isLoggedIn
|
return sessionStore.isLoggedIn()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun client(): Flow<Optional<MatrixClient>> {
|
fun client(): Flow<Optional<MatrixClient>> {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.element.android.x.matrix
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
|
|
||||||
|
|
||||||
object MatrixInstance {
|
object MatrixInstance {
|
||||||
@@ -11,6 +10,7 @@ object MatrixInstance {
|
|||||||
private lateinit var instance: Matrix
|
private lateinit var instance: Matrix
|
||||||
|
|
||||||
fun init(context: Context, coroutineScope: CoroutineScope) {
|
fun init(context: Context, coroutineScope: CoroutineScope) {
|
||||||
|
//setupTracing("warn,matrix_sdk::sliding_sync=info")
|
||||||
instance = Matrix(coroutineScope, context)
|
instance = Matrix(coroutineScope, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user