Page MenuHomePhabricator

[native] community joiner modal
ClosedPublic

Authored by varun on Nov 21 2024, 7:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 27, 6:02 PM
Unknown Object (File)
Thu, Mar 27, 5:14 PM
Unknown Object (File)
Thu, Mar 27, 1:05 PM
Unknown Object (File)
Thu, Mar 27, 9:11 AM
Unknown Object (File)
Wed, Mar 26, 8:57 PM
Unknown Object (File)
Tue, Mar 25, 11:47 PM
Unknown Object (File)
Mar 14 2025, 11:47 PM
Unknown Object (File)
Mar 14 2025, 11:47 PM
Subscribers

Details

Summary

Depends on D13995

we'll navigate to this modal from the community drawer button in D13987 and from the bottom sheet in D13986

Test Plan

tested that the tabs work as expected and all the community threads display in the right tab. tested the join/leave behavior in previous diff, which also has a video with the modal

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
ashoat requested changes to this revision.Nov 23 2024, 6:16 AM
ashoat added inline comments.
native/components/community-joiner-modal.react.js
46 ↗(On Diff #45933)

Is this the best way to check which communities belong where? What happens if a community gets renamed? I feel like IDs might be better

87–101 ↗(On Diff #45933)

Should these be in useCallbacks?

109–112 ↗(On Diff #45933)

Should this be in a useMemo?

134 ↗(On Diff #45933)

Talked through this offline yesterday, but yeah we should improve this from mixed

134–142 ↗(On Diff #45933)

Shouldn't this be in a useCallback?

150 ↗(On Diff #45933)

Shouldn't this be in a useMemo?

153 ↗(On Diff #45933)

Shouldn't this be in a useMemo?

This revision now requires changes to proceed.Nov 23 2024, 6:16 AM
native/components/community-joiner-modal.react.js
46 ↗(On Diff #45933)

You're right. I wrote a script here that I'll need you to run to get the IDs

D14145

native/components/community-joiner-modal.react.js
35 ↗(On Diff #46372)

This should say IDs instead of names, but the comment will be removed entirely when I populate the list

ashoat requested changes to this revision.Dec 12 2024, 11:21 AM

This is close, but requesting changes due to the volume of comments below

native/components/community-joiner-modal.react.js
35 ↗(On Diff #46372)

Probably best to put it in a separate file, as I imagine it'll be somewhat long

40 ↗(On Diff #46372)

Why is this fallback necessary? CommunityJoinerModalParams seems to indicate that we'll always have params.communities

73 ↗(On Diff #46372)

Can you remind me in what cases the keyserver returns a community with a missing threadInfo? Should we consider just not having the keyserver return those communities, or do we need them for something?

125–130 ↗(On Diff #46372)

Nit: shorthand

152 ↗(On Diff #46372)

Curious why we need this

Also, should this be defined at the top level instead of in a React.useMemo?

native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46372)

This is cool! Didn't know about these types. How'd you find out about them?

39 ↗(On Diff #46372)

Besides the missing +, this type doesn't seem right. The second part of the & says it is an object with precisely one property: route. If that's the case, then what's the point of including SceneRendererProps there?

Guessing you probably want ... as well:

+renderScene: (props: SceneRendererProps & { +route: Route<>, ... }) => React$Node,
48 ↗(On Diff #46372)

Same feedback as above here (consider ...)

This revision now requires changes to proceed.Dec 12 2024, 11:21 AM
native/components/community-joiner-modal.react.js
73 ↗(On Diff #46372)

the keyserver should never return a community with a missing threadInfo, but it's technically possible. (we call fetchPrivilegedThreadInfos on the keyserver to get the threadInfos, and this function could return an empty array.) we can just omit the communities that are missing a threadInfo and maybe add a log on the keyserver to point out the unexpected state

152 ↗(On Diff #46372)

passing initialLayout can improve the initial rendering performance. you're right that this should be at the top level since it's static

native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46372)

I git grep'd for these types in the flow-typed subdirectory. but now that i look more closely, these are both any-typed in native/flow-typed/npm/react-native-gesture-handler_v2.x.x.js...

declare export type AnimatedValue = any;
declare export type ViewStyle = any;
native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46372)

Maybe better to copy-paste the "Vaguely copied" lines definitions in native/flow-typed/npm/@react-navigation/core_v6.x.x.js

native/components/community-joiner-modal.react.js
152 ↗(On Diff #46372)

Let's calculate this based on our styles. First we factor them out:

// @flow

export const modalBorderWidth = 2;

export const modalMarginHorizontal = 15;

export const modalPadding = 12;

Then we update native/components/modal.react.js to use those.

And finally we calculate this initialLayout width based on useWindowDimensions().width - 2 * (sum of above)

native/components/community-joiner-modal.react.js
35 ↗(On Diff #46372)

creating a new file called lib/facts/communities.js for these IDs

address most of the diff feedback

native/components/community-joiner-modal.react.js
73 ↗(On Diff #46372)

decided to leave the keyserver API as-is for now

native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46372)

i think we should pair on this

ashoat requested changes to this revision.Jan 30 2025, 10:51 AM
ashoat added inline comments.
native/components/community-joiner-modal.react.js
45 ↗(On Diff #46849)

You removed the defaultCommunities fallback, but it appears to still be necessary, because you have a ?. here.

Can you either:

  1. As initially requested, explain why the fallback is necessary (why you have a ?.) and reintroduce ?? defaultCommunities, or
  2. Simply remove the ?.
140 ↗(On Diff #46849)

Nit: can we rename this to tabProps, and strip the tabBar prefix from each of the properties below? I think it's kind of misleading to call it screenOptions, as it seems to indicate it's a React Navigation screenOptions (but it's not)

142 ↗(On Diff #46849)

Where is this used?

143–145 ↗(On Diff #46849)

In your latest video in D13994, in light mode the background color doesn't match the background color of the modal. Can you share an updated video here, and if the issue is still apparent, can you adjust the background colors to match?

We might need to introduce a new color in useColors that has the right color for light mode and dark mode... but even better would be to see what we're doing in the modal (we can probably just use the same color we have there)

146–148 ↗(On Diff #46849)

Where is this used?

native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46849)

These are any-typed – as discussed earlier, can you copy-paste the "Vaguely copied" lines definitions in native/flow-typed/npm/@react-navigation/core_v6.x.x.js?

This revision now requires changes to proceed.Jan 30 2025, 10:51 AM
native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46849)

https://phab.comm.dev/D13996?id=46372#inline-79685 I left a comment here, but I think we should pair on this. I can create a follow-up task to unblock this for now, since you're probably busy this weekend. I was copying and pasting a lot from that file, which feels wrong...

native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46849)

I think you should just copy-paste from the file. Can you try updating the diff with copy-paste, and then we can discuss from there?

native/components/community-joiner-modal.react.js
45 ↗(On Diff #46849)
diff --git a/native/components/community-joiner-modal.react.js b/native/components/community-joiner-modal.react.js
index 6ea7820d70..e739f631f0 100644
--- a/native/components/community-joiner-modal.react.js
+++ b/native/components/community-joiner-modal.react.js
@@ -42,7 +42,7 @@ const routes = [
 
 function CommunityJoinerModal(props: Props): React.Node {
   const { params } = props.route;
-  const communities = params?.communities;
+  const { communities } = params;
 
   const viewerID = useSelector(
     state => state.currentUserInfo && state.currentUserInfo.id,

at some point i think flow was complaining about this line so i added the fallback but i must be misremembering. however, flow is happy with the above change so i'll remove the ?.

native/components/community-joiner-modal.react.js
142 ↗(On Diff #46849)

doesn't appear to be used anywhere, removing

143–145 ↗(On Diff #46849)

we're using modalBackground there. I'm going to use modalBackground here as well instead of tabBarBackground

Simulator Screenshot - iPhone 16 Pro Max - 2025-02-03 at 20.22.52.png (2×1 px, 145 KB)

146–148 ↗(On Diff #46849)

it's not, thanks for catching

native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46849)

getting two flow errors:

varun@varuns-MacBook-Pro native % flow
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ navigation/chat-tab-bar-button.react.js:82:19

Cannot create TabBarItem element because inexact InterpolationConfigType [1] is incompatible with exact
InterpolationConfigType [2] in the first parameter of property position.interpolate. [incompatible-exact]

     navigation/chat-tab-bar-button.react.js
      79│
      80│     return (
      81│       <TabBarItem
      82│         position={position.current}
      83│         route={route}
      84│         navigationState={dummyNavigationState}
      85│         onPress={dummyCallback}

     flow-typed/npm/react-native-tab-view_v3.x.x.js
 [2]  39│     interpolate(config: InterpolationConfigType): AnimatedInterpolation;

     ../node_modules/react-native/Libraries/Animated/nodes/AnimatedValue.js
 [1] 230│     config: InterpolationConfigType<OutputT>,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ navigation/chat-tab-bar-button.react.js:82:19

Cannot create TabBarItem element because inexact InterpolationConfigType [1] is incompatible with exact
InterpolationConfigType [2] in the first parameter of property interpolate of the return value of property
position.interpolate. [incompatible-exact]

     navigation/chat-tab-bar-button.react.js
      79│
      80│     return (
      81│       <TabBarItem
      82│         position={position.current}
      83│         route={route}
      84│         navigationState={dummyNavigationState}
      85│         onPress={dummyCallback}

     flow-typed/npm/react-native-tab-view_v3.x.x.js
 [2]  39│     interpolate(config: InterpolationConfigType): AnimatedInterpolation;

     ../node_modules/react-native/Libraries/Animated/nodes/AnimatedInterpolation.js
 [1] 336│     config: InterpolationConfigType<NewOutputT>,



Found 2 errors

not sure how to resolve these

native/components/community-joiner-modal.react.js
175–178 ↗(On Diff #46900)

Can this be replaced with ...tabProps?

183–186 ↗(On Diff #46900)

We can just replace these four lines with tabProps

native/flow-typed/npm/react-native-tab-view_v3.x.x.js
6–9 ↗(On Diff #46849)

Thanks for trying. Let's bring back your original approach, where you imported the any-types from react-native-gesture-handler/@react-native

native/navigation/chat-tab-bar-button.react.js
46 ↗(On Diff #46900)

On first glance, this seemed like it was solving an extremely serious issue... the kind that should've been fixed in a separate diff, with an Urgent issue so we could prioritize shipping a fix.

Because of how serious it seemed, I opted to spend some time analyzing the code. Turns out it's not actually used in our case, so there is no urgent issue to solve. But I wish that the same "alarm bells" had been ringing in your head, and that you had spent some time analyzing the issue, and explaining why it didn't need an immediate fix...

To avoid further review churn on the Flow types (given difference between AnimatedValue and AnimatedInterpolation), I went ahead and made the changes myself

This revision is now accepted and ready to land.Feb 4 2025, 7:33 PM

CI

native/components/community-joiner-modal.react.js
143–145 ↗(On Diff #46849)

The image isn't visible. Can you attach it?

This revision was automatically updated to reflect the committed changes.

Ah I accidentally landed an older version of this diff

reverted this change. reopening to reintroduce the change

This revision is now accepted and ready to land.Feb 11 2025, 7:27 PM
This revision was automatically updated to reflect the committed changes.