Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3525874
D8105.id27463.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D8105.id27463.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D8105: [native] Add functions to filter thread descendants in community drawer
Attached
Detach File
Event Timeline
Log In to Comment