Page MenuHomePhabricator

[native] Add CommunityDrawerContent
ClosedPublic

Authored by inka on Nov 24 2022, 8:48 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 15, 9:01 PM
Unknown Object (File)
Sun, Dec 15, 9:01 PM
Unknown Object (File)
Sun, Dec 15, 9:01 PM
Unknown Object (File)
Sun, Dec 15, 9:01 PM
Unknown Object (File)
Sun, Dec 15, 9:01 PM
Unknown Object (File)
Sun, Dec 15, 9:01 PM
Unknown Object (File)
Sun, Dec 15, 9:01 PM
Unknown Object (File)
Sun, Dec 15, 9:01 PM
Subscribers

Details

Summary

Linear issue: https://linear.app/comm/issue/ENG-1881/community-navigation-drawer-on-native
Add a custom drawer content implementation to be passed to DrawerNavigator, displaying a CommunityDrawerItemCommunity for each community.

Test Plan

Added this component to AppsDirectory and check that it allows to navigate to threads, the elements open and close as expected. Checked that when only one community is present it is open by defalut and none is open when there are more
communities. Checked that the app dooesn't crash when there are no communities.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

native/navigation/community-drawer-content.react.js
113–120 ↗(On Diff #18823)

Styles will be revisited during styling
ENG-2343

inka requested review of this revision.Nov 24 2022, 9:02 AM

Add lightmode colour

native/themes/colors.js
88 ↗(On Diff #18854)

This value will be revisited during styling ENG-2343

tomek requested changes to this revision.Nov 30 2022, 10:08 AM
tomek added inline comments.
native/navigation/community-drawer-content.react.js
11–12 ↗(On Diff #18854)

We can merge these imports

21–22 ↗(On Diff #18854)

We should avoid redefining variables - it reduces readability and maintainability.

In this case we can either create a new variable to hold communities with the suffix, or do that as a part of the selector. It seems like the first option should be more performant.

25–27 ↗(On Diff #18854)

It's better to avoid using numbers with special meaning. When we have no community open, we should rather use null to indicate that.

Also, is there a requirement to open the first community by default? Shouldn't we keep all of them closed initially?
Opening the first community might be confusing for the user, when there are more communities and the drawer was opened while the user had a thread from other community opened.

32–38 ↗(On Diff #18854)

We should use a callback and a version of set state where (state) => new state argument is used.

40 ↗(On Diff #18854)

Use callback

56–88 ↗(On Diff #18854)

It might be a good idea to move this to a function with descriptive name.

73–76 ↗(On Diff #18854)

Do we have a constant that describes all these types? Do we use the same set of types in other places?

With current implementation it would be extremely hard to find all the places that have to be updated if we decide to introduce a new thread type.

This revision now requires changes to proceed.Nov 30 2022, 10:08 AM

Address review

native/navigation/community-drawer-content.react.js
25–27 ↗(On Diff #18854)

The requirement is that when there is only one community it should be open by default. I don't think this will open a community when there are more than one... I have two communities and none of them is open by default.

Fix typo in import (changes in previous diff)

tomek added inline comments.
native/navigation/community-drawer-content.react.js
56–61 ↗(On Diff #19168)

We can use a simpler notation

71–72 ↗(On Diff #19168)

It is a good idea to add type annotations for these to make the code more readable

72 ↗(On Diff #19168)

In context of this function the fact that community names have suffixes doesn't matter and we can skip this so that the name is simpler

25–27 ↗(On Diff #18854)

Makes sense!

This revision is now accepted and ready to land.Dec 6 2022, 4:50 AM

Changes due to chanes is previous diff