Page MenuHomePhabricator

D8105.id27463.diff
No OneTemporary

D8105.id27463.diff

diff --git a/native/utils/drawer-utils.react.js b/native/utils/drawer-utils.react.js
--- a/native/utils/drawer-utils.react.js
+++ b/native/utils/drawer-utils.react.js
@@ -91,4 +91,44 @@
return results;
}
-export { flattenDrawerItemsData };
+function findAllDescendantIDs(
+ data: $ReadOnlyArray<CommunityDrawerItemData<TextStyle>>,
+): $ReadOnlyArray<string> {
+ const results = [];
+ for (const item of data) {
+ results.push(item.threadInfo.id);
+ results.concat(findAllDescendantIDs(item.itemChildren));
+ }
+ return results;
+}
+
+function findThreadChildrenItems(
+ data: $ReadOnlyArray<CommunityDrawerItemData<TextStyle>>,
+ id: string,
+): ?$ReadOnlyArray<CommunityDrawerItemData<TextStyle>> {
+ for (const item of data) {
+ if (item.threadInfo.id === id) {
+ return item.itemChildren;
+ }
+ const result = findThreadChildrenItems(item.itemChildren, id);
+ if (result) {
+ return result;
+ }
+ }
+ return undefined;
+}
+
+function filterThreadAndDescendantIDs(
+ ids: $ReadOnlyArray<string>,
+ allItems: $ReadOnlyArray<CommunityDrawerItemData<TextStyle>>,
+ id: string,
+): $ReadOnlyArray<string> {
+ const childItems = findThreadChildrenItems(allItems, id);
+ if (!childItems) {
+ return [];
+ }
+ const descendants = findAllDescendantIDs(childItems);
+ return ids.filter(item => !descendants.includes(item) && !(item === id));
+}
+
+export { flattenDrawerItemsData, filterThreadAndDescendantIDs };

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 6:37 PM (9 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700788
Default Alt Text
D8105.id27463.diff (1 KB)

Event Timeline