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.