Skip to content

Commit 95e823e

Browse files
authored
Merge pull request #566 from stytchauth/stytchui-funk
Fix some funk in StytchUI
2 parents 123715c + 579e605 commit 95e823e

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

Sources/StytchUI/StytchUIClient/StytchUIClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum StytchUIClient {
1616
/// - Publishes a `Void` value each time a dismissal event occurs.
1717
/// - Never completes with a failure, so subscribers can safely remain attached for the lifetime of the application.
1818
public static var dismissUI: AnyPublisher<Void, Never> {
19-
B2BAuthenticationManager.dismissUI
19+
dismissUIPublisher.eraseToAnyPublisher()
2020
}
2121

2222
private static let dismissUIPublisher = PassthroughSubject<Void, Never>()

Sources/StytchUI/StytchUIClient/ViewControllers/AuthHomeViewController/AuthHomeViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ extension AuthHomeViewController {
9898
}
9999

100100
@objc func authenticateBiometricsButtonTapped() {
101-
StytchB2BUIClient.startLoading()
101+
StytchUIClient.startLoading()
102102
Task {
103103
do {
104-
StytchB2BUIClient.stopLoading()
104+
StytchUIClient.stopLoading()
105105
_ = try await StytchClient.biometrics.authenticate(parameters: .init())
106106
} catch {
107-
StytchB2BUIClient.stopLoading()
107+
StytchUIClient.stopLoading()
108108
ErrorPublisher.publishError(error)
109109
presentErrorAlert(error: error)
110110
}

Sources/StytchUI/StytchUIClient/ViewControllers/AuthHomeViewController/AuthHomeViewModel.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,22 @@ extension AuthHomeViewModel {
2626
if state.config.supportsBiometricsAndOAuth {
2727
productComponents.appendIfNotPresent(.oAuthButtons)
2828
productComponents.appendIfNotPresent(.biometrics)
29+
} else {
30+
productComponents.appendIfNotPresent(.oAuthButtons)
2931
}
3032
case .biometrics:
3133
if state.config.supportsBiometricsAndOAuth {
3234
productComponents.appendIfNotPresent(.biometrics)
3335
productComponents.appendIfNotPresent(.oAuthButtons)
36+
} else {
37+
productComponents.appendIfNotPresent(.biometrics)
3438
}
3539
}
3640
}
3741

38-
if state.config.supportsInputProducts, state.config.supportsOauth || state.config.supportsBiometrics {
42+
let shouldShowBiometrics = StytchClient.biometrics.availability.isAvailableRegistered && state.config.supportsBiometrics
43+
44+
if state.config.supportsInputProducts, state.config.supportsOauth || shouldShowBiometrics {
3945
if let index = productComponents.firstIndex(of: .inputProducts) {
4046
if index == 0 {
4147
productComponents.insert(.divider, at: 1)

Sources/StytchUI/StytchUIClient/ViewControllers/AuthInputViewController/AuthInputViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class AuthInputViewController: BaseViewController<AuthInputState, AuthInpu
4343
private lazy var inputs: [Input] = {
4444
var inputs: [Input] = []
4545

46-
if let otpMethods = viewModel.state.config.otpOptions?.methods {
46+
if viewModel.state.config.supportsOTP == true, let otpMethods = viewModel.state.config.otpOptions?.methods {
4747
for method in otpMethods {
4848
switch method {
4949
case .sms:

Sources/StytchUI/StytchUIClient/ViewControllers/OAuthViewController/OAuthViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ final class OAuthViewController: BaseViewController<OAuthState, OAuthViewModel>
3030

3131
@objc private func didTapOAuthButton(sender: UIControl) {
3232
guard let (_, provider) = viewModel.state.config.oauthProviders.enumerated().first(where: { $0.offset == sender.tag }) else { return }
33-
StytchB2BUIClient.startLoading()
33+
StytchUIClient.startLoading()
3434
Task {
3535
do {
36-
StytchB2BUIClient.stopLoading()
36+
StytchUIClient.stopLoading()
3737
try await viewModel.startOAuth(provider: provider)
3838
} catch {
39-
StytchB2BUIClient.stopLoading()
39+
StytchUIClient.stopLoading()
4040
try? await EventsClient.logEvent(parameters: .init(eventName: "ui_authentication_failure", error: error))
4141
ErrorPublisher.publishError(error)
4242
presentErrorAlert(error: error)

0 commit comments

Comments
 (0)