-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Frontend] Clear reports and datapoints state when switching agencies #16
[Frontend] Clear reports and datapoints state when switching agencies #16
Conversation
38f0cf2
to
67ca814
Compare
); | ||
} | ||
|
||
deconstructor() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the advice here https://stackoverflow.com/questions/59345330/how-do-you-dispose-a-reaction-defined-in-a-class-constructor to handle disposing of a reaction defined in a mobx class, this might be overkill since at least right now we never need to dispose of this since we never need to de-instantiate any of our mobx stores
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@terryttsai this is very cool!
I tried it out locally and one thing I noticed is that if you switch to a different agency while on a particular report, you get an error:
This is probably fine (I'm not sure what the right behavior should be in this case?) but just wanted to call it out in case there's an easy fix.
Thanks for calling that out, I put up a fix for this case by navigating you back to the reports list when you try to switch agencies while on a report: https://www.loom.com/share/f99f609f88e44633868835bc80363ef9 I also replace the browser navigation stack so you can't press the back button and go back to that report page since you'd see an error there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay!
Description of the change
https://www.loom.com/share/8ec11e17e8004218859c43a77141a461
Set up reactions to clear reports and datapoints state when user switches agencies.
For the Reports page, we only fetch the reports list when the user navigates to that page, OR the user agency id has changed.
For the Metrics page, we only fetch the datapoints when the user navigates to that page, OR the user agency id has changed.
This means if the user switches agencies while on a different page, we clear, but don't fetch the new data until the user visits a page that needs to load that data, minimizing needless fetches.
Type of change
Related issues
Closes #15
Checklists
Development
This box MUST be checked by the submitter prior to merging:
These boxes should be checked by the submitter prior to merging:
Code review
These boxes should be checked by reviewers prior to merging: