Merge pull request #8786 from element-hq/feature/bma/setupSecureBackup

Fix setup secure backup
This commit is contained in:
Benoit Marty 2024-03-21 09:27:29 +01:00 committed by GitHub
commit b23757c989
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 2 deletions

1
changelog.d/8786.bugfix Normal file
View File

@ -0,0 +1 @@
Fix infinite loading on secure backup setup ("Re-Authentication needed" bottom sheet).

View File

@ -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 ->

View File

@ -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
}

View File

@ -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) {