-
Notifications
You must be signed in to change notification settings - Fork 1
YPE-1133: fix broken reader when auth is not enabled #133
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
base: main
Are you sure you want to change the base?
Conversation
bmanquen
commented
Feb 3, 2026
- Conditionally render the user menu in the bible reader toobar so that the reader does not crash if user has auth disabled.
- Conditionally call the useAuth() hook only if the user has auth enabled.
- Write test to ensure that the bible reader can be used with auth disabled from the YouVersionProvider.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
🦋 Changeset detectedLatest commit: d33022b The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
fafc1e1 to
01b8d4d
Compare
Greptile OverviewGreptile SummaryFixed crash when auth is disabled by conditionally rendering the UserMenu component based on an Key Changes
Technical ApproachThe fix correctly leverages React's conditional rendering to prevent the Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App
participant Provider as YouVersionProvider
participant Context as YouVersionContext
participant Reader as BibleReader
participant Toolbar
participant Menu as UserMenu
Note over App,Menu: Auth Disabled Flow
App->>Provider: includeAuth: false
Provider->>Context: authEnabled: false
Reader->>Toolbar: render
Toolbar->>Context: check authEnabled
Context-->>Toolbar: false
Toolbar->>Toolbar: skip UserMenu
Note over Menu: UserMenu not rendered<br/>useYVAuth not called
Note over App,Menu: Auth Enabled Flow
App->>Provider: includeAuth: true
Provider->>Context: authEnabled: true
Reader->>Toolbar: render
Toolbar->>Context: check authEnabled
Context-->>Toolbar: true
Toolbar->>Menu: render UserMenu
Menu-->>Toolbar: display auth UI
|
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.
3 files reviewed, 1 comment
| if (includeAuth) { | ||
| return ( | ||
| <StorybookEnvCheck requiredEnvVars={requiredEnvVars}> | ||
| <YouVersionProvider | ||
| appKey={import.meta.env.STORYBOOK_YOUVERSION_APP_KEY || ''} | ||
| authRedirectUrl={import.meta.env.STORYBOOK_AUTH_REDIRECT_URL || ''} | ||
| apiHost={import.meta.env.STORYBOOK_YOUVERSION_API_HOST} | ||
| includeAuth={true} | ||
| theme={getTheme(context.globals.theme)} | ||
| > | ||
| <Story /> | ||
| </YouVersionProvider> | ||
| </StorybookEnvCheck> | ||
| ); | ||
| } |
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.
Use early return instead of if-else to reduce nesting. Invert the condition to check !includeAuth first and return early with the simpler case (without auth), then return the auth case at the end.
Context Used: Rule from dashboard - Avoid unnecessary negations and else blocks to reduce nesting and improve code readability. Use earl... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/.storybook/preview.tsx
Line: 52:66
Comment:
Use early return instead of if-else to reduce nesting. Invert the condition to check `!includeAuth` first and return early with the simpler case (without auth), then return the auth case at the end.
**Context Used:** Rule from `dashboard` - Avoid unnecessary negations and else blocks to reduce nesting and improve code readability. Use earl... ([source](https://app.greptile.com/review/custom-context?memory=b2f865f5-91b5-4c90-89be-43dc9c513644))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.- Conditionally render the user menu in the bible reader toobar so that the reader does not crash if user has auth disabled. - Conditionally call the useAuth() hook only if the user has auth enabled. - Write test to ensure that the bible reader can be used with auth disabled from the YouVersionProvider.
01b8d4d to
d33022b
Compare
cameronapak
left a comment
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.
Good work! One suggestion added
| @@ -245,42 +289,7 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) { | |||
| )} | |||
| > | |||
| <div className="yv:grid yv:w-full yv:grid-cols-7 yv:items-center yv:max-w-lg yv:gap-0.5"> | |||
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.
{authEnabled && <UserMenu />}When authEnabled=false, this renders nothing but the grid still has 7 columns (grid-cols-7). This may cause layout shift or misalignment.
Suggestion: Can you adjust grid columns dynamically or render a placeholder <div />?