Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,29 +297,28 @@ function ThreadNavigationSidebarPane(
),
[threadListV2Enabled, projects, selectedProjectRefs],
);
// Not short-circuited on v2 the way `scopedProjects` is: the project
// sections below partition these same lists, so emptying them here leaves
// every section with no rows and the sidebar blank.
const scopedThreads = useMemo(
() =>
threadListV2Enabled
? []
: selectedProjectRefs === null
? threads
: threads.filter((thread) =>
selectedProjectRefs.has(scopedProjectKey(thread.environmentId, thread.projectId)),
),
[threadListV2Enabled, selectedProjectRefs, threads],
selectedProjectRefs === null
? threads
: threads.filter((thread) =>
selectedProjectRefs.has(scopedProjectKey(thread.environmentId, thread.projectId)),
),
[selectedProjectRefs, threads],
);
const scopedPendingTasks = useMemo(
() =>
threadListV2Enabled
? []
: selectedProjectRefs === null
? pendingTasks
: pendingTasks.filter((pendingTask) =>
selectedProjectRefs.has(
scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
),
selectedProjectRefs === null
? pendingTasks
: pendingTasks.filter((pendingTask) =>
selectedProjectRefs.has(
scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
),
[threadListV2Enabled, pendingTasks, selectedProjectRefs],
),
[pendingTasks, selectedProjectRefs],
);
const groups = useMemo(
() =>
Expand Down
14 changes: 14 additions & 0 deletions apps/mobile/src/features/threads/threadListV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,20 @@ describe("buildThreadListV2ProjectSectionItems", () => {
settledShelfExpanded: true,
});

// A regression guard: the sidebar once fed these sections an empty thread
// list, which drops every header too and leaves the whole sidebar blank.
it("drops a project entirely when it is handed no threads", () => {
const populated = buildThreadListV2ProjectSectionItems({
sections: [section("alpha", ["a1"]), section("beta", ["b1"])],
});
expect(populated.filter((item) => item.type === "v2-project-header")).toHaveLength(2);

const starved = buildThreadListV2ProjectSectionItems({
sections: [section("alpha", []), section("beta", [])],
});
expect(starved).toEqual([]);
});

it("puts every project's rows under its own header, in section order", () => {
const items = buildThreadListV2ProjectSectionItems({
sections: [section("alpha", ["a1"]), section("beta", ["b1", "b2"])],
Expand Down
Loading