digidem / comapeo-mobile

The next version of Mapeo mobile
GNU General Public License v3.0
5 stars 1 forks source link

updating active project id results in unexpected navigation in certain situations #406

Open achou11 opened 3 months ago

achou11 commented 3 months ago

Discovered via https://github.com/digidem/comapeo-mobile/pull/405. As an example, the invite flow for someone joining a project has the following unexpected UX:

  1. Receive invite
  2. Accept invite
  3. Press "Go to Sync"
  4. Navigates to sync, but then app "resets" and you end up on Map screen

Think i have a decent idea of the issue(s). First, after accepting an invite, we have a hardcoded setTimeout of 5 seconds before updating the active project id state:

https://github.com/digidem/comapeo-mobile/blob/c09460f425a5e21f1a3db456a14735c2a59d9476/src/frontend/hooks/server/invites.ts#L38-L51

this aligns with what i see where i could update the code to navigate to some other screen (instead of sync) and the same behavior would be observed.

i think the bigger issue is that calling switchActiveProject(projectId); basically resets/remounts the navigation, which means that things like the initialRouteName are re-calculated and applied. I think the remounting happens because we're wrapping our navigations with suspense, and many of the suspense queries are dependent on that active project id state that we're updating (which seems reasonable).

Not sure what the proper way of fixing is, but hoping that I'm identifying the problem correctly to begin with 🤔

achou11 commented 3 months ago

Short term solution: remove the "Go to Sync" button 😄