From 5cd78c02aacb697f2cfe19fead1b29a4e22d9f95 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 19 Mar 2024 18:23:50 +0100 Subject: [PATCH 1/3] Ensure the keys are updated as soon as possible. Else it seems that we had to wait for the next sync response. --- .../crosssigning/CrossSigningSettingsViewModel.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt index 51c7928e1f..3ea66b5dfe 100644 --- a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt @@ -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(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) { From 1155c43fe07c10e46e3e187b40b028bff30e04aa Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 19 Mar 2024 17:47:52 +0100 Subject: [PATCH 2/3] BootstrapReAuthFragment: fix infinite loading wheel by submitting at start up. --- .../crypto/recover/BootstrapReAuthFragment.kt | 7 ++++++ .../recover/BootstrapReAuthViewModel.kt | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthViewModel.kt diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt index f32ba735a1..d259f1f738 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt @@ -21,6 +21,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.view.isVisible +import androidx.lifecycle.ViewModelProvider import com.airbnb.mvrx.parentFragmentViewModel import com.airbnb.mvrx.withState import dagger.hilt.android.AndroidEntryPoint @@ -43,6 +44,12 @@ class BootstrapReAuthFragment : views.bootstrapRetryButton.debouncedClicks { submit() } views.bootstrapCancelButton.debouncedClicks { cancel() } + + val viewModel = ViewModelProvider(this).get(BootstrapReAuthViewModel::class.java) + if (!viewModel.isFirstSubmitDone) { + viewModel.isFirstSubmitDone = true + submit() + } } private fun submit() = withState(sharedViewModel) { state -> diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthViewModel.kt new file mode 100644 index 0000000000..8dedaaa15a --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthViewModel.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.crypto.recover + +import androidx.lifecycle.ViewModel + +class BootstrapReAuthViewModel : ViewModel() { + var isFirstSubmitDone = false +} From 24c7131ab2cabda2bd092ff4f86a85938e27049c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 20 Mar 2024 10:56:35 +0100 Subject: [PATCH 3/3] towncrier --- changelog.d/8786.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/8786.bugfix diff --git a/changelog.d/8786.bugfix b/changelog.d/8786.bugfix new file mode 100644 index 0000000000..5b295dcf54 --- /dev/null +++ b/changelog.d/8786.bugfix @@ -0,0 +1 @@ + Fix infinite loading on secure backup setup ("Re-Authentication needed" bottom sheet).