-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: add hide own repository filter checkbox #96
feat: add hide own repository filter checkbox #96
Conversation
src/pages/stats/[login].tsx
Outdated
? repositories?.filter( | ||
// apply hideOwnRepo filter if checked | ||
(repoData) => | ||
repoData.repository.owner.login !== session?.user.login | ||
) |
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.
The logic that filters out own repos is written here and replicated in lines 48-51.
Maybe we should either run it once on top of this function or extract the filtering logic in a separate function, what do you think?
src/pages/stats/[login].tsx
Outdated
@@ -225,6 +241,16 @@ export default function Stats() { | |||
onChange={(e) => setSearchQuery(e.target.value)} | |||
/> | |||
</div> | |||
<div className="flex sm:items-start items-center"> |
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.
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.
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.
They get centered on mobile/smaller screens
👷 Deploy request for public-github-stats pending review.Visit the deploys page to approve it
|
src/pages/stats/[login].tsx
Outdated
const filteredOutOwnRepos = filterOutOwnRepos(filteredReposBySearchQuery); | ||
|
||
// filter repositories based on search query | ||
const query = searchQuery.toLowerCase(); | ||
const filterRepos = repositories?.filter((repoData) => | ||
repoData.repository.name.toLowerCase().includes(query) | ||
); | ||
return hideOwnRepo ? filteredOutOwnRepos : filteredReposBySearchQuery; |
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.
Here you're running filterOutOwnRepos
in any case, but if hideOwnRepo
is false it is unnecessary.
I'd probably see this better with an if statement to return early, or if we want to keep it more functional with the ternary you should run filterOutOwnRepos
directly inside the "then" of the ternary.
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.
LGTM, thank you!
No description provided.