Skip to content

Commit b23757c

Browse files
authored
Merge pull request #8786 from element-hq/feature/bma/setupSecureBackup
Fix setup secure backup
2 parents c0da558 + 24c7131 commit b23757c

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

changelog.d/8786.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix infinite loading on secure backup setup ("Re-Authentication needed" bottom sheet).

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import android.view.LayoutInflater
2121
import android.view.View
2222
import android.view.ViewGroup
2323
import androidx.core.view.isVisible
24+
import androidx.lifecycle.ViewModelProvider
2425
import com.airbnb.mvrx.parentFragmentViewModel
2526
import com.airbnb.mvrx.withState
2627
import dagger.hilt.android.AndroidEntryPoint
@@ -43,6 +44,12 @@ class BootstrapReAuthFragment :
4344

4445
views.bootstrapRetryButton.debouncedClicks { submit() }
4546
views.bootstrapCancelButton.debouncedClicks { cancel() }
47+
48+
val viewModel = ViewModelProvider(this).get(BootstrapReAuthViewModel::class.java)
49+
if (!viewModel.isFirstSubmitDone) {
50+
viewModel.isFirstSubmitDone = true
51+
submit()
52+
}
4653
}
4754

4855
private fun submit() = withState(sharedViewModel) { state ->
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2024 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.crypto.recover
18+
19+
import androidx.lifecycle.ViewModel
20+
21+
class BootstrapReAuthViewModel : ViewModel() {
22+
var isFirstSubmitDone = false
23+
}

vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import im.vector.app.core.resources.StringProvider
2727
import im.vector.app.features.auth.PendingAuthHandler
2828
import im.vector.app.features.login.ReAuthHelper
2929
import kotlinx.coroutines.Dispatchers
30+
import kotlinx.coroutines.Job
3031
import kotlinx.coroutines.flow.launchIn
3132
import kotlinx.coroutines.flow.onEach
3233
import kotlinx.coroutines.launch
@@ -52,6 +53,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
5253
private val pendingAuthHandler: PendingAuthHandler,
5354
) : VectorViewModel<CrossSigningSettingsViewState, CrossSigningSettingsAction, CrossSigningSettingsViewEvents>(initialState) {
5455

56+
private var observeCrossSigningJob: Job? = null
57+
5558
init {
5659
observeCrossSigning()
5760
}
@@ -90,6 +93,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
9093
}
9194
}
9295
})
96+
// Force a fast refresh of the data
97+
observeCrossSigning()
9398
} catch (failure: Throwable) {
9499
handleInitializeXSigningError(failure)
95100
} finally {
@@ -114,7 +119,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
114119
// ) { myDevicesInfo, mxCrossSigningInfo ->
115120
// myDevicesInfo to mxCrossSigningInfo
116121
// }
117-
session.flow().liveCrossSigningInfo(session.myUserId)
122+
observeCrossSigningJob?.cancel()
123+
observeCrossSigningJob = session.flow().liveCrossSigningInfo(session.myUserId)
118124
.onEach { data ->
119125
val crossSigningKeys = data.getOrNull()
120126
val xSigningIsEnableInAccount = crossSigningKeys != null
@@ -128,7 +134,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
128134
xSigningKeyCanSign = xSigningKeyCanSign
129135
)
130136
}
131-
}.launchIn(viewModelScope)
137+
}
138+
.launchIn(viewModelScope)
132139
}
133140

134141
private fun handleInitializeXSigningError(failure: Throwable) {

0 commit comments

Comments
 (0)