{(() => {
const renderInboxIssue = ({
issue,
@@ -2436,6 +2436,55 @@ export function Inbox() {
const hasChildren = childIssues.length > 0;
const isExpanded = hasChildren && !collapsedInboxParents.has(issue.id);
const canArchiveIssue = canArchiveFromTab && group.searchSection === "none";
+ const renderChildIssueRows = (
+ children: Issue[],
+ depth: number,
+ seen: ReadonlySet
,
+ ): ReactNode[] =>
+ children.flatMap((child) => {
+ if (seen.has(child.id)) return [];
+ const nextSeen = new Set(seen);
+ nextSeen.add(child.id);
+ const childNavIdx = childFlatIndex.get(child.id) ?? -1;
+ const isChildSelected = selectedIndex === childNavIdx;
+ const grandchildIssues = group.childrenByIssueId.get(child.id) ?? [];
+ const childHasChildren = grandchildIssues.length > 0;
+ const childIsExpanded = childHasChildren && !collapsedInboxParents.has(child.id);
+ const childRow = renderInboxIssue({
+ issue: child,
+ depth,
+ selected: isChildSelected,
+ hasChildren: childHasChildren,
+ isExpanded: childIsExpanded,
+ childCount: grandchildIssues.length,
+ collapseParentId: child.id,
+ allowArchive: canArchiveIssue,
+ });
+ const isChildArchiving = archivingIssueIds.has(child.id);
+ const row = (
+ setSelectedIndex(childNavIdx)}
+ >
+ {canArchiveIssue ? (
+ archiveIssueMutation.mutate(child.id)}
+ >
+ {childRow}
+
+ ) : childRow}
+
+ );
+
+ return childIsExpanded
+ ? [row, ...renderChildIssueRows(grandchildIssues, depth + 1, nextSeen)]
+ : [row];
+ });
const parentRow = renderInboxIssue({
issue,
depth: 0,
@@ -2459,36 +2508,7 @@ export function Inbox() {
) : parentRow));
if (isExpanded) {
- for (const child of childIssues) {
- const childNavIdx = childFlatIndex.get(child.id) ?? -1;
- const isChildSelected = selectedIndex === childNavIdx;
- const childRow = renderInboxIssue({
- issue: child,
- depth: 1,
- selected: isChildSelected,
- allowArchive: canArchiveIssue,
- });
- const isChildArchiving = archivingIssueIds.has(child.id);
- elements.push(
- setSelectedIndex(childNavIdx)}
- >
- {canArchiveIssue ? (
- archiveIssueMutation.mutate(child.id)}
- >
- {childRow}
-
- ) : childRow}
-
,
- );
- }
+ elements.push(...renderChildIssueRows(childIssues, 1, new Set([issue.id])));
}
}