Basically I have a
MutableState<String>
on my MainActivity which I pass to one of my screen composables and I update its value like this
state.value = googleToken
after I get a token on onActivityResult from GoogleSignInActivity. Inside my login screen i have a onCommit block that I execute whenever this token changes.
val googleIdToken by googleIdTokenState
onCommit(googleIdToken) {
googleIdToken?.let { token ->
loginViewModel.checkIfGoogleUserExists(token) {
// If it exists, login and navigate "Home" immediately
// If it does not exist, navigate to next screen "Register" for the user to input a username
}
}
}
My problem comes when for example, the user navigates to register screen and then navigates back and again clicks on the "Sign in with Google" button. on the onActivityResult I will get the same token but the MutableState won't change. I managed to make it change by creating it with a
neverEqualPolicy()
but of course the onCommit block won't execute again