Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setup secure backup #8786

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8786.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix infinite loading on secure backup setup ("Re-Authentication needed" bottom sheet).
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -52,6 +53,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
private val pendingAuthHandler: PendingAuthHandler,
) : VectorViewModel<CrossSigningSettingsViewState, CrossSigningSettingsAction, CrossSigningSettingsViewEvents>(initialState) {

private var observeCrossSigningJob: Job? = null

init {
observeCrossSigning()
}
Expand Down Expand Up @@ -90,6 +93,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
}
}
})
// Force a fast refresh of the data
observeCrossSigning()
} catch (failure: Throwable) {
handleInitializeXSigningError(failure)
} finally {
Expand All @@ -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
Expand All @@ -128,7 +134,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
xSigningKeyCanSign = xSigningKeyCanSign
)
}
}.launchIn(viewModelScope)
}
.launchIn(viewModelScope)
}

private fun handleInitializeXSigningError(failure: Throwable) {
Expand Down
Loading