mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
Rename completion to callback and simplify actor usage. (#6141)
This commit is contained in:
+16
-15
@@ -28,7 +28,7 @@ class AuthenticationServerSelectionViewModel: AuthenticationServerSelectionViewM
|
||||
|
||||
// MARK: Public
|
||||
|
||||
var completion: ((AuthenticationServerSelectionViewModelResult) -> Void)?
|
||||
@MainActor var callback: ((AuthenticationServerSelectionViewModelResult) -> Void)?
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
@@ -41,20 +41,15 @@ class AuthenticationServerSelectionViewModel: AuthenticationServerSelectionViewM
|
||||
// MARK: - Public
|
||||
|
||||
override func process(viewAction: AuthenticationServerSelectionViewAction) {
|
||||
Task {
|
||||
await MainActor.run {
|
||||
switch viewAction {
|
||||
case .confirm:
|
||||
completion?(.confirm(homeserverAddress: state.bindings.homeserverAddress))
|
||||
case .dismiss:
|
||||
completion?(.dismiss)
|
||||
case .getInTouch:
|
||||
getInTouch()
|
||||
case .clearFooterError:
|
||||
guard state.footerErrorMessage != nil else { return }
|
||||
withAnimation { state.footerErrorMessage = nil }
|
||||
}
|
||||
}
|
||||
switch viewAction {
|
||||
case .confirm:
|
||||
Task { await callback?(.confirm(homeserverAddress: state.bindings.homeserverAddress)) }
|
||||
case .dismiss:
|
||||
Task { await callback?(.dismiss) }
|
||||
case .getInTouch:
|
||||
Task { await getInTouch() }
|
||||
case .clearFooterError:
|
||||
Task { await clearFooterError() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +66,12 @@ class AuthenticationServerSelectionViewModel: AuthenticationServerSelectionViewM
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
/// Clear any errors shown in the text field footer.
|
||||
@MainActor private func clearFooterError() {
|
||||
guard state.footerErrorMessage != nil else { return }
|
||||
withAnimation { state.footerErrorMessage = nil }
|
||||
}
|
||||
|
||||
/// Opens the EMS link in the user's browser.
|
||||
@MainActor private func getInTouch() {
|
||||
let url = BuildSettings.onboardingHostYourOwnServerLink
|
||||
|
||||
Reference in New Issue
Block a user