( idsToFilter: $ReadOnlyArray<string>, allItems: $ReadOnlyArray<CommunityDrawerItemData<T>>, threadID: string, )
| 100 | } |
| 101 | |
| 102 | function filterOutThreadAndDescendantIDs<T>( |
| 103 | idsToFilter: $ReadOnlyArray<string>, |
| 104 | allItems: $ReadOnlyArray<CommunityDrawerItemData<T>>, |
| 105 | threadID: string, |
| 106 | ): $ReadOnlyArray<string> { |
| 107 | const childItems = findThreadChildrenItems(allItems, threadID); |
| 108 | if (!childItems) { |
| 109 | return []; |
| 110 | } |
| 111 | const descendants = findAllDescendantIDs(childItems); |
| 112 | const descendantsSet = new Set(descendants); |
| 113 | return idsToFilter.filter( |
| 114 | item => !descendantsSet.has(item) && item !== threadID, |
| 115 | ); |
| 116 | } |
| 117 | |
| 118 | export { flattenDrawerItemsData, filterOutThreadAndDescendantIDs }; |
no test coverage detected