Page MenuHomePhabricator

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

Authored by inka on Jun 6 2023, 8:16 AM.
Tags
None
Referenced Files
F3525874: D8105.id27463.diff
Mon, Dec 23, 6:37 PM
F3524230: D8105.diff
Mon, Dec 23, 11:46 AM
Unknown Object (File)
Thu, Dec 5, 8:29 PM
Unknown Object (File)
Thu, Dec 5, 2:33 AM
Unknown Object (File)
Thu, Dec 5, 2:32 AM
Unknown Object (File)
Wed, Dec 4, 4:10 AM
Unknown Object (File)
Nov 8 2024, 5:52 PM
Unknown Object (File)
Nov 5 2024, 10:09 PM
Subscribers

Details

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.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

inka requested review of this revision.Jun 6 2023, 8:33 AM
tomek requested changes to this revision.Jun 7 2023, 3:56 AM
tomek added inline comments.
native/utils/drawer-utils.react.js
95

Wondering if we have to be specific about TextStyle. Can we make this a generic T?

122–124

Can we find more descriptive names? id and ids might be a little confusing.

130

We should create a Set from this so that we avoid linear search in the next line

131
This revision now requires changes to proceed.Jun 7 2023, 3:56 AM
tomek added inline comments.
native/utils/drawer-utils.react.js
102–115 ↗(On Diff #27521)

Function name might be a little confusing. It isn't obvious if we want to return all the threads except descendants or only the descendants. Can we improve it?

This revision is now accepted and ready to land.Jun 12 2023, 3:38 AM