Open OwenLaRosa opened 5 years ago
Even to one new to coding, this issue was pretty simple to fix. I simply added 'setLoggingIn(false)' after both the if and else blocks within the handleLoginResponse method. This should terminate the activity indicator and re-enable the locked fields and buttons in the LoginViewController.
setLoggingIn(false) in handle login response inside else block helped me to enable buttons again to try another username and password to get login information correct
I think calling setLoggingIn(false)
inside the completionHandler for the UIAlertAction
is the proper way of handling this. That way, resetting the login page is triggered when the user clicks the OK
button when the showLoginFailure
alert pops up 🤷🏾
My solution: func showLoginFailure(message: String) { .... setLoggingIn(false) }
did the same thing @EdwardPhaniOS. I also added that to the loginViaWebsiteTapped method if the getRequestToken response was successful because the logginIn method was hanging after going to the browser and coming back again.
@IBAction func loginViaWebsiteTapped() { setLoggingIn(true) TMDBClient.getRequestToken { (success, error) in if success { ...................... self.setLoggingIn(false) } } }
In lesson 7, we added an activity indicator to the login view. The view appears and starts spinning when the login process begins, and stops spinning and disappears when the login is complete.
But what happens if the login doesn't complete? Try an incorrect username/password or modifying the API key. After dismissing the alert, the spinner keeps spinning. You'll also notice that the text fields can't be edited, nor can you press any of the buttons.
We already know where to add code for when the login fails. To fix this issue, try calling
setLoggingIn()
in the appropriate places to ensure UI changes appropriately to match the "logging in" state.