mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Ensure the keys are updated as soon as possible. Else it seems that we had to wait for the next sync response.
This commit is contained in:
parent
c0da558c96
commit
5cd78c02aa
1 changed files with 9 additions and 2 deletions
|
@ -27,6 +27,7 @@ import im.vector.app.core.resources.StringProvider
|
|||
import im.vector.app.features.auth.PendingAuthHandler
|
||||
import im.vector.app.features.login.ReAuthHelper
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -52,6 +53,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
|
|||
private val pendingAuthHandler: PendingAuthHandler,
|
||||
) : VectorViewModel<CrossSigningSettingsViewState, CrossSigningSettingsAction, CrossSigningSettingsViewEvents>(initialState) {
|
||||
|
||||
private var observeCrossSigningJob: Job? = null
|
||||
|
||||
init {
|
||||
observeCrossSigning()
|
||||
}
|
||||
|
@ -90,6 +93,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
})
|
||||
// Force a fast refresh of the data
|
||||
observeCrossSigning()
|
||||
} catch (failure: Throwable) {
|
||||
handleInitializeXSigningError(failure)
|
||||
} finally {
|
||||
|
@ -114,7 +119,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
|
|||
// ) { myDevicesInfo, mxCrossSigningInfo ->
|
||||
// myDevicesInfo to mxCrossSigningInfo
|
||||
// }
|
||||
session.flow().liveCrossSigningInfo(session.myUserId)
|
||||
observeCrossSigningJob?.cancel()
|
||||
observeCrossSigningJob = session.flow().liveCrossSigningInfo(session.myUserId)
|
||||
.onEach { data ->
|
||||
val crossSigningKeys = data.getOrNull()
|
||||
val xSigningIsEnableInAccount = crossSigningKeys != null
|
||||
|
@ -128,7 +134,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
|
|||
xSigningKeyCanSign = xSigningKeyCanSign
|
||||
)
|
||||
}
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
private fun handleInitializeXSigningError(failure: Throwable) {
|
||||
|
|
Loading…
Reference in a new issue