refactor: remove unnecessary getUserLoggedIn API call in User component#1257
Merged
jescalada merged 7 commits intofinos:mainfrom Oct 27, 2025
Merged
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1257 +/- ##
=======================================
Coverage 82.64% 82.64%
=======================================
Files 70 70
Lines 3007 3007
Branches 501 501
=======================================
Hits 2485 2485
Misses 419 419
Partials 103 103 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jescalada
approved these changes
Oct 26, 2025
Contributor
jescalada
left a comment
There was a problem hiding this comment.
LGTM! I was wondering if we should do a bit of renaming here to make things more obvious for future contributors?
- The
Userview is really just the User page or User Profile, so renaming it to UserProfile would be better. - The
isProfileboolean could also use a better name - although it's not very clear what it's being used for. Perhaps something likeconst editable = !id || loggedInUser.adminmight work? - This is beyond the scope of this PR, but it would be nice to rename all usages of
gitAccount(which is actually the GH username) at some point since it no longer makes sense now that we're identifying users by email. Added #1258 to track this
Contributor
Author
|
@jescalada thanks for looking at this - I have:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR simplifies and improves the logic of the
User.tsxview.Previously, the component was making an unnecessary API call to
getUserLoggedInto check if the current user is an admin — information that’s already available through theUserContextprovided by the Dashboard layout. Other components (e.g.,RepoDetails.tsxandRepositories.tsx) already rely on this context, making the extra call redundant.Additionally, the component contained several code quality issues:
isAdminstate variableuseEffectbranchesisProfile)Fix
UserContextfor admin checks: Replaced thegetUserLoggedInAPI call with context access to determine admin status.getUserLoggedIncall and theisAdminstate variable.isProfilestate with a derived constant:const isProfile = !id;getUsercall for cleaner, more maintainable code.