mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fix multiple server confirmation request crashes and show a modal indicator sooner
This commit is contained in:
committed by
Stefan Ceriu
parent
32ec97a866
commit
20a84dd896
+12
-12
@@ -58,8 +58,12 @@ class ServerConfirmationScreenViewModel: ServerConfirmationScreenViewModelType,
|
||||
Task { state.window = window }
|
||||
case .confirm:
|
||||
switch state.mode {
|
||||
case .confirmation: Task { await confirmServer() }
|
||||
case .picker: Task { await pickServer() }
|
||||
case .confirmation:
|
||||
startLoading()
|
||||
Task { await confirmServer() }
|
||||
case .picker:
|
||||
startLoading()
|
||||
Task { await pickServer() }
|
||||
}
|
||||
case .changeServer:
|
||||
actionsSubject.send(.changeServer)
|
||||
@@ -69,6 +73,9 @@ class ServerConfirmationScreenViewModel: ServerConfirmationScreenViewModelType,
|
||||
// MARK: - Private
|
||||
|
||||
private func confirmServer() async {
|
||||
defer { stopLoading() }
|
||||
startLoading()
|
||||
|
||||
let homeserver = authenticationService.homeserver.value
|
||||
|
||||
// If the login mode is unknown, the service hasn't been configured and we need to do it now.
|
||||
@@ -78,11 +85,6 @@ class ServerConfirmationScreenViewModel: ServerConfirmationScreenViewModelType,
|
||||
return
|
||||
}
|
||||
|
||||
// Note: We don't show the spinner until now as it isn't needed if the service is already
|
||||
// configured and we're about to use password based login
|
||||
startLoading()
|
||||
defer { stopLoading() }
|
||||
|
||||
switch await authenticationService.configure(for: homeserver.address, flow: authenticationFlow) {
|
||||
case .success:
|
||||
await fetchLoginURLIfNeededAndContinue()
|
||||
@@ -107,6 +109,9 @@ class ServerConfirmationScreenViewModel: ServerConfirmationScreenViewModelType,
|
||||
}
|
||||
|
||||
private func pickServer() async {
|
||||
defer { stopLoading() }
|
||||
startLoading()
|
||||
|
||||
guard let accountProvider = state.bindings.pickerSelection else {
|
||||
fatalError("It shouldn't be possible to confirm without a selection.")
|
||||
}
|
||||
@@ -118,11 +123,6 @@ class ServerConfirmationScreenViewModel: ServerConfirmationScreenViewModelType,
|
||||
return
|
||||
}
|
||||
|
||||
// Note: We don't show the spinner until now as it isn't needed if the service is already
|
||||
// configured and we're about to use password based login
|
||||
startLoading()
|
||||
defer { stopLoading() }
|
||||
|
||||
switch await authenticationService.configure(for: accountProvider, flow: authenticationFlow) {
|
||||
case .success:
|
||||
await fetchLoginURLIfNeededAndContinue()
|
||||
|
||||
Reference in New Issue
Block a user