HomePhabricator
Diffusion Comm 3be963261f7b

[native] Add functions to filter thread descendants in community drawer

Description

[native] Add functions to filter thread descendants in community drawer

Summary:
issue: https://linear.app/comm/issue/ENG-3412/fix-nested-flatlist-in-navigation-community-drawer
We will keep the expanded state communnity items as an array that hols ids of expanded elements. When a parent item is collapsed, so are all it's children, and their children, an so on
(so we can collapse and expand an item to quicly collapse all its descendants). In order to do so, we need to know which ids in expanded array belong to this chats descendants.

findThreadChildrenItems finds the chat in question in the CommunityDrawerItemData recursive structure - to obtain an array containing only descenants of this chat.
findAllDescendantIDs then creates a flat array with ids of all descendants.
we then filter ids (expanded array) to remove all of those found decsendants and the chat that is being collapsed.

filterThreadAndDescendantIDs will be called when a chat is being collapsed.

Test Plan: Run filterThreadAndDescendantIDs on different data, checked that only descenatants of chat whose id is passed, and the chat itself, are being removed from ids.

Reviewers: tomek, kamil, kuba

Reviewed By: tomek

Subscribers: ashoat

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

Details