HomePhabricator
Diffusion Comm 78feba2a4c7c

[native] Add drawer utils for flattening items structure

Description

[native] Add drawer utils for flattening items structure

Summary:
issue: https://linear.app/comm/issue/ENG-3412/fix-nested-flatlist-in-navigation-community-drawer
Currently the community drawer on native consists of nested FlatLists. This is bad for performance, we want to have a single FlatList. For this reason the recursive structure of type
CommunityDrawerItemData has to be "flattened" - every item has to end up in to top level array, that will be passed to the single FlatList.

CommunityDrawerItemDataFlattened is CommunityDrawerItemData with the following changes:

  • itemChildren was removed, because we are making the data structure flat, so we are moving nested children too the top level
  • isCommunity was added, to know which items are community items to be able to create proper components for them (they take different props)
  • hasChildren was added to be able to render the expand button properly (before we checked itemChildren.length)
  • itemStyle was added, because now that the items are not nested in each other an item needs to know its indentation and background

The background prop is not read only, because we need the last visible chat in the open community to know it's the last, and get background: 'end'. The best way to do this is to create
all items, and then look at the last item of the array and change its prop. This is the same approach as we use to determine which chat bubble endsCluster.

Test Plan: Checked for random chats that all their children are visible and their styles are correct

Reviewers: tomek, kuba, kamil

Reviewed By: tomek

Subscribers: ashoat

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

Details

Provenance
InkaSokolowskaAuthored on Jun 6 2023, 2:18 AM
Reviewer
tomek
Differential Revision
D8104: [native] Add drawer utils for flattening items structure
Parents
rCOMMd978cf9b6c46: comm-dev.sh - remove unnecessary 'exit 1's
Branches
Unknown
Tags
Unknown