Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move draft observation editing redirect to side-effect #876

Open
gmaclennan opened this issue Dec 5, 2024 · 0 comments
Open

Move draft observation editing redirect to side-effect #876

gmaclennan opened this issue Dec 5, 2024 · 0 comments

Comments

@gmaclennan
Copy link
Member

gmaclennan commented Dec 5, 2024

Currently when the app is opened with an unsaved draft observation, we dynamically change the initialRoute of the RootNavigator to show the observation edit screen, or the preset chooser screen. The consequence of this is that we have no screens in the stack in this state, where-as at other times we aways have the hometabs screen at the the base of the stack, so closing the edit observation screen is more complicated, and has to reset the whole stack.

We should change the architecture of this so that homeTabs is always mounted, and address the case of an unsaved draft observation by redirecting as a side-effect during render of either the root navigator, or render of the homeTabs screen.

We need to ensure that this side-effect does not run during use of the app (e.g. when the user starts editing an observation). We can do this by only running the side effect on mount (fragile), or doing some other check before navigating.

We should also change the hooks that is checking a draft observation exists so that it does not re-render every time we edit the draft observation.

After changing this, we can remove the code that resets the navigation stack when saving / closing the edit observation screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant