-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Account Profile rewritten #18076
Account Profile rewritten #18076
Conversation
This pull request introduces 4 alerts and fixes 2 when merging 8cde558 into 0c26dca - view on LGTM.com new alerts:
fixed alerts:
|
This pull request introduces 4 alerts and fixes 2 when merging 8cde558 into 1157075 - view on LGTM.com new alerts:
fixed alerts:
|
8cde558
to
796d08b
Compare
…rewrite_account_profile
…rewrite_account_profile
}, [url, username, userId]); | ||
|
||
function UserAvatar({ url, username, userId, ...props }) { | ||
const avatarUrl = useAvatarUrl({ url, username, userId }); |
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.
Why not lift this hook up to the parent? Instead of having two mutually exclusive props (url
and userId
) that can be accidentally set together, it can receive only url
.
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.
In my opinion, the idea of having a specific component like UserAvatar
should allow me to not bother about how I get the URL. If we make it that only the URL is accepted, the behaviour won't differ from the Avatar
component from fuselage
.
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.
I agree it's great to have some encapsulation, but it should be closely-knit. If I've the option to pass the user ID, then why did I need to set username
too if it can be resolved the same way url
is? If the answer is "sometimes you already have it and we don't need to recompute", then this url
and username
resolution shouldn't really be here.
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.
As an example, in UserAvatar
is a dumb component in UserAvatarEditor
when it serves as a view for suggestions, but also it's used as the de facto component to show user avatar. If UserAvatar
must have some logic to show the avatar for a user, then Avatar
should be used elsewhere.
…into new/rewrite_account_profile * 'rewrite/accounts' of github.com:RocketChat/Rocket.Chat: [FIX] Cannot open admin when server uses ROOT_URL with subpath (#18105) (#18147) [FIX] App details returns to apps table, instead of previous page (#18080) [FIX] Clipboard not working when permalinking a pinned message (#18047) [FIX] "Add reaction" icon missing when the viewport size is smaller than 500px (#18110) [FIX] Jitsi opening twice (#18111) [FIX] Email notifications were still being sent for online users (#18088) [FIX] The livechat agent activity monitor wasn't being initialised because due to an internal error (#18090)
5402457
to
630dafc
Compare
630dafc
to
3a5689e
Compare
|
||
export function UserAvatarEditor({ username, setAvatarObj }) { | ||
function UserAvatarSuggestions({ suggestions, setAvatarObj, setNewAvatarSource, disabled, ...props }) { |
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.
Prefer event listeners (on*
) over setters (set*
) passed through props.
setAvatarObj(suggestion); | ||
setNewAvatarSource(suggestion.blob); |
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.
If these setters are called together, it's interesting to trigger a single event for them, the reason being each setter call its own component update and we should let the parent component to decide if it two updates are needed or not (e.g. a single dispatch
call from a useReducer
hook).
Co-authored-by: Tasso Evangelista <[email protected]>
…ocket.Chat into new/rewrite_account_profile
This pull request introduces 4 alerts when merging 8aa5c56 into b7668c5 - view on LGTM.com new alerts:
|
Proposed changes
Rewrite
User Profile
Page using ReactIssue(s)
How to test or reproduce
Screenshots
Types of changes
Checklist
Changelog
Further comments