-
Notifications
You must be signed in to change notification settings - Fork 281
♻️ (frontend) Make the code more readable by simplifying conditional logic #844
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -46,12 +46,11 @@ export const DocsGrid = ({ | |||||||||||||||
void fetchNextPage(); | ||||||||||||||||
}; | ||||||||||||||||
|
||||||||||||||||
const title = | ||||||||||||||||
target === DocDefaultFilter.MY_DOCS | ||||||||||||||||
? t('My docs') | ||||||||||||||||
: target === DocDefaultFilter.SHARED_WITH_ME | ||||||||||||||||
? t('Shared with me') | ||||||||||||||||
: t('All docs'); | ||||||||||||||||
const title = { | ||||||||||||||||
[DocDefaultFilter.MY_DOCS]: t('My docs'), | ||||||||||||||||
[DocDefaultFilter.SHARED_WITH_ME]: t('Shared with me'), | ||||||||||||||||
[DocDefaultFilter.ALL_DOCS]: t('All docs'), | ||||||||||||||||
}[target] | ||||||||||||||||
|
||||||||||||||||
Comment on lines
+53
to
54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Directly indexing the mapping with [target] assumes that target always matches one of the map keys. Consider adding a default fallback (e.g., using the nullish coalescing operator) to prevent 'title' from being undefined for unexpected target values.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was just to test how copilot does a review 🙂 Maybe based on the suggestion uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would keep it the way it is. if someone where to add another key to the enum There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or
Suggested change
|
||||||||||||||||
return ( | ||||||||||||||||
<Box | ||||||||||||||||
|
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.
Yes the default fallback
t('All docs')
as to be defined as target can beundefined
:docs/src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGrid.tsx
Line 16 in 003d550