mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Make sure the Recovery Key option is shown on the IdentityConfirmationScreen when available. (#3699)
There was a race condition where 2 different states could be processed at the same time. * Fix unit test The view model wasn't stored, so relying the current value publisher didn't have time to fire before deinit.
This commit is contained in:
parent
88e63b297e
commit
a70189d318
@ -25,18 +25,13 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
|
||||
|
||||
super.init(initialViewState: IdentityConfirmationScreenViewState(learnMoreURL: appSettings.encryptionURL))
|
||||
|
||||
userSession.sessionSecurityStatePublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] state in
|
||||
Task {
|
||||
Task { [weak self] in
|
||||
for await state in userSession.sessionSecurityStatePublisher.values {
|
||||
// We need to call this inside an AsyncSequence otherwise there's a race condition when the method suspends.
|
||||
await self?.updateWithSessionSecurityState(state)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
Task {
|
||||
await updateWithSessionSecurityState(userSession.sessionSecurityStatePublisher.value)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
@ -104,6 +104,8 @@ struct IdentityConfirmationScreen: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct IdentityConfirmationScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static var viewModel = makeViewModel()
|
||||
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
IdentityConfirmationScreen(context: viewModel.context)
|
||||
@ -113,7 +115,7 @@ struct IdentityConfirmationScreen_Previews: PreviewProvider, TestablePreview {
|
||||
})
|
||||
}
|
||||
|
||||
private static var viewModel: IdentityConfirmationScreenViewModel {
|
||||
static func makeViewModel() -> IdentityConfirmationScreenViewModel {
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
userSession.sessionSecurityStatePublisher = CurrentValuePublisher<SessionSecurityState, Never>(.init(verificationState: .unverified, recoveryState: .enabled))
|
||||
|
Loading…
x
Reference in New Issue
Block a user