mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Fix / annoying loading to get active sessions
Start with what's known locally
This commit is contained in:
parent
320dc4accd
commit
4506b7d6e6
2 changed files with 20 additions and 2 deletions
|
@ -426,6 +426,15 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
|||
// ==============================================================================================================
|
||||
|
||||
private fun refreshMyDevice() {
|
||||
session.getUserDevices(session.myUserId).map {
|
||||
DeviceInfo(
|
||||
user_id = session.myUserId,
|
||||
deviceId = it.deviceId,
|
||||
displayName = it.displayName()
|
||||
)
|
||||
}.let {
|
||||
refreshCryptographyPreference(it)
|
||||
}
|
||||
// TODO Move to a ViewModel...
|
||||
session.getDevicesList(object : MatrixCallback<DevicesListResponse> {
|
||||
override fun onSuccess(data: DevicesListResponse) {
|
||||
|
|
|
@ -115,11 +115,20 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
|||
* It can be any mobile devices, and any browsers.
|
||||
*/
|
||||
private fun refreshDevicesList() {
|
||||
if (session.isCryptoEnabled() && !session.sessionParams.credentials.deviceId.isNullOrEmpty()) {
|
||||
if (!session.sessionParams.credentials.deviceId.isNullOrEmpty()) {
|
||||
// display something asap
|
||||
val localKnown = session.getUserDevices(session.myUserId).map {
|
||||
DeviceInfo(
|
||||
user_id = session.myUserId,
|
||||
deviceId = it.deviceId,
|
||||
displayName = it.displayName()
|
||||
)
|
||||
}
|
||||
|
||||
setState {
|
||||
copy(
|
||||
// Keep known list if we have it, and let refresh go in backgroung
|
||||
devices = this.devices.takeIf { it is Success } ?: Loading()
|
||||
devices = this.devices.takeIf { it is Success } ?: Success(localKnown)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue