Page MenuHomePhabricator

[lib/native] introduce UserProfileMessageButton
ClosedPublic

Authored by ginsu on Sep 20 2023, 1:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 7:19 AM
Unknown Object (File)
Wed, Dec 11, 11:50 PM
Unknown Object (File)
Tue, Dec 10, 1:02 AM
Unknown Object (File)
Mon, Dec 9, 3:39 PM
Unknown Object (File)
Sat, Dec 7, 8:03 PM
Unknown Object (File)
Sat, Dec 7, 9:40 AM
Unknown Object (File)
Fri, Dec 6, 12:21 PM
Unknown Object (File)
Sat, Nov 30, 12:06 PM
Subscribers

Details

Summary

This diff introduces the UserProfileMessageButton component that will be rendered on a user profile. This button will be used to navigate to a thread between the viewer and the user of the profile

Figma designs (left is when there in no block in either direction and right is when there is a block in either direction):

Screenshot 2023-09-22 at 4.34.33 PM.png (1×1 px, 277 KB)

Depends on D9247

Test Plan

Please see the demo video below

anonymous user:

Screenshot 2023-09-20 at 4.49.07 PM.png (1×1 px, 750 KB)

block in either direction is active:

Screenshot 2023-09-22 at 4.15.11 PM.png (1×1 px, 732 KB)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ginsu added inline comments.
native/components/user-profile-message-button.react.js
16–17

I broke down the prop types down instead of using PendingPersonalThreadUserInfo here. This was some feedback I got from @kamil in an older diff. I also personally think it makes it more readable and super clear to any dev that this is exactly what is needed for this component, but happy to change this if others think otherwise

native/components/user-profile.react.js
72–74

This is for the case if we view an anonymous profile

ginsu requested review of this revision.Sep 20 2023, 2:02 PM

we should also not show message button if the user and/or viewer is blocked

native/components/user-profile-message-button.react.js
15–18 ↗(On Diff #31377)

I broke down the prop types down instead of using PendingPersonalThreadUserInfo here. This was some feedback I got from @kamil in an older diff. I also personally think it makes it more readable and super clear to any dev that this is exactly what is needed for this component, but happy to change this if others think otherwise

native/components/user-profile.react.js
78–80 ↗(On Diff #31377)

This is for the case if we view an anonymous profile or there is block active in either direction

atul requested changes to this revision.Sep 26 2023, 11:45 AM

Let's use existing relationshipBlockedInEitherDirection

native/components/user-profile-message-button.react.js
30 ↗(On Diff #31377)

Can we give this a more descriptive name? Like

const { dismiss: dismissBottomSheetModal } = useBottomSheetModal();
36–42 ↗(On Diff #31377)

We could wrap this in useMemo to short-circuit re-renders, but benefit is probably marginal at best and this is more readable... so probably makes sense to leave as is

native/components/user-profile.react.js
26–29 ↗(On Diff #31377)

Looking at this, had a strong hunch that this logic wasn't unique to UserProfile

Looking at relationships-utils, we seem to have a relationshipBlockedInEitherDirection:

1075ef.png (440×1 px, 111 KB)

which seems like what we want to use here?

92–102 ↗(On Diff #31377)

Could wrap this higher-level component w/ useMemo to short circuit re-renders if you think that makes sense

This revision now requires changes to proceed.Sep 26 2023, 11:45 AM
native/components/user-profile.react.js
92–102 ↗(On Diff #31377)

Left this as is, since the benefit is probably marginal at best and this is more readable

lib/shared/relationship-utils.js
49 ↗(On Diff #31461)

Made this optional so that we can use this function even if userInfo is potentially null/undefined. This should not change the logic, since a user should not have a block on a null (anonymous) user or a null user can't have a block on the viewer and will just still return false

ginsu retitled this revision from [native] introduce UserProfileMessageButton to [lib/native] introduce UserProfileMessageButton.Sep 27 2023, 11:48 AM

Thanks for addressing feedback!

This revision is now accepted and ready to land.Sep 28 2023, 5:30 PM