HomePhabricator
Diffusion Comm d719301f17d4

[native] Flatten nested FlatLists in community drawer

Description

[native] Flatten nested FlatLists in community drawer

Summary:
issue: https://linear.app/comm/issue/ENG-3933/flatten-the-list-of-items-to-render-in-communitydrawercontent
CommunityDrawerItemCommunity and CommunityDrawerItemChat are no longer needed:

CommunityDrawerItemCommunity existed mostly to take care of some styles, but because of changes needed to remove nested FlatLists, the styles are now handled differently - by the itemData.itemStyle prop.

CommunityDrawerItemChat existed to hold the expanded state for items on deeper levels, but this state (as discussed in ENG-3934 ) is now handled by CommunityDrawerContent.

Because the expanded state for all items is now handled by CommunityDrawerContent, openCommunity state is no longer needed. We can check which community is open by expanded.includes(id). expanded initial state is communitiesSuffixed.length === 1 ? [communitiesSuffixed[0].id] : [], because if there is only one community it is supposed to be open by default. Communnity items still need a different function for toggleExpanded though, because when one community is opened, the other one collapses automatically.

Test Plan:
Checked that the drawer bahaves as before:

  • only one community is open at a time
  • chats on lower levels can be open simultaneously
  • collapsing a chat causes all its children to collapse
  • items are styled properly

Reviewers: tomek, kuba, kamil

Reviewed By: tomek

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D8112

Details