From 1155c43fe07c10e46e3e187b40b028bff30e04aa Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 19 Mar 2024 17:47:52 +0100 Subject: [PATCH] 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 +}