PeriodPals / periodpals

3 stars 1 forks source link

Fix sync problem with auth screens #187

Closed charliemangano closed 2 weeks ago

charliemangano commented 2 weeks ago

Description:

We have noticed a problem with how we handle the authentication, leading to having to click the "SignUp"/"SignIn" button two times to properly sign in. We believe it is caused by a syncing problem, either directly with our authentication repository (Supabase), or in our code itself with side effects being handled improperly. This task aims at finding and fixing this problem.

Done:

Steps to Completion:

charliemangano commented 2 weeks ago

The problem is indeed with how we handle our side effects, as the callbacks of the view model execute, at least partly, only after we've checked in the authentication screens if the login in/signing up was successful:

// in `SignIn` and `SignUp` screens
authenticationViewModel.logInWithEmail(email, password)            // this does not finish executing

val loginSuccess = userState is UserAuthenticationState.Success    // before this happens

So our authentication screens think that the operation failed, when it has just not finished executing.