ground-android icon indicating copy to clipboard operation
ground-android copied to clipboard

[Code health] Design flaw in main startup flow

Open gino-m opened this issue 1 year ago • 1 comments

Play services and login are tied to an event triggered by MainViewModel and handled by MainActivity. The MainActivity may not be active when this event is triggered, so it will sometimes miss the sign-in event, for example when the app is temporarily in the background (e.g., when Play services are being installed, and when started in the background while debugging from Android Studio).

The initialization flow "evolved" while we were still learning modern Android dev, rather than being thoughtfully designed. @shobhitagarwal1612 @scolsen @anandwana001, any ideas on how this should work in practice?

gino-m avatar Dec 16 '24 17:12 gino-m

Some initial thoughts:

  • We could always check for Play services, ToS, and auth on resume of MainActivity instead of just in StartupFragment
  • In that case, MainUiState may not be correct - instead, Play services init and ToS could probably can be recast as StartupState or similar
  • Rather than receive auth changes as navigationRequest events, MainActivity should listen for the current state on app resume and redirect to the appropriate page iff the sign in Play->sign in->ToS flow isn't complete.

gino-m avatar Dec 16 '24 17:12 gino-m