Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Story
correctly block unauthed users from pages that require auth
previously, a page that required authorization would show the spinning modal indefinitely, instead of showing the message that informs the user they must be signed in. this is because the variable that determined whether the spinner should show, always remained true.
this commit breaks out the logic to first check if there is a user. what renders on the page is based on that.
checking for the presence of a session has to come after all of the hooks so we don't violate the react-hooks/rules-of-hooks rule. ref: https://legacy.reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level we return the loading state in two different locations because it's rendered based on separate conditions. when isLoading is true because we don't have a user, it doesn't ever become false. that's why we were previously returning the loading spinner indefinitely. using a guard clause with an early return inside the api methods also violates the react-hooks/rules-of-hooks rule.
Screenshots / Video
Screen.Recording.2023-11-30.at.01.15.45.PM.mp4
Testing