Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Link Login CTA during email lookup #4250

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ final class LinkLoginViewController: UIViewController {

let emailAddress = dataSource.manifest.accountholderCustomerEmailAddress ?? dataSource.elementsSessionContext?.prefillDetails?.email
if let emailAddress, !emailAddress.isEmpty {
// Immediately set the button state to loading here to bypass the debouncing by the textfield.
footerButton?.isLoading = true
formView.prefillEmailAddress(emailAddress)

let phoneNumber = dataSource.manifest.accountholderPhoneNumber ?? dataSource.elementsSessionContext?.prefillDetails?.formattedPhoneNumber
Expand Down Expand Up @@ -153,13 +155,15 @@ final class LinkLoginViewController: UIViewController {

private func lookupAccount(with emailAddress: String) {
formView.emailTextField.showLoadingView(true)
footerButton?.isLoading = true

dataSource
.lookup(emailAddress: emailAddress)
.observe { [weak self, weak formView] result in
.observe { [weak self, weak formView, weak footerButton] result in
formView?.emailTextField.showLoadingView(false)
guard let self else { return }
footerButton?.isLoading = false

guard let self else { return }
switch result {
case .success(let response):
if response.exists {
Expand Down
Loading