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
Unknown Object (File)
Fri, Nov 8, 5:52 PM
Unknown Object (File)
Tue, Nov 5, 10:09 PM
Unknown Object (File)
Tue, Nov 5, 9:11 AM
Unknown Object (File)
Tue, Nov 5, 9:11 AM
Unknown Object (File)
Mon, Nov 4, 10:52 AM
Unknown Object (File)
Mon, Oct 28, 12:00 PM
Unknown Object (File)
Oct 15 2024, 1:27 AM
Unknown Object (File)
Oct 2 2024, 8:01 AM
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
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #27463)

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

122–124 ↗(On Diff #27463)

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

130 ↗(On Diff #27463)

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

131 ↗(On Diff #27463)
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