Commit e7c1710d authored by Robert Knight's avatar Robert Knight

Restore the behavior of hiding threads if the root annotation is missing

This matches the behavior from earlier versions when tabs were shown. Unlike
previously, we now always show tabs in the sidebar, so this means that
conversations without a root annotation will always be hidden in this context,
whereas previously they could be hidden until you performed a search, which
could be confusing.
parent c52e06d3
...@@ -197,6 +197,27 @@ describe('sidebar/helpers/thread-annotations', () => { ...@@ -197,6 +197,27 @@ describe('sidebar/helpers/thread-annotations', () => {
}); });
}); });
it('filters threads where the root annotation does not exist', () => {
fakeBuildThread.returns({
children: [
{
annotation: null,
children: [annotationFixtures.oldReply()],
},
],
});
fakeThreadState.showTabs = true;
fakeThreadState.selection.selectedTab = 'annotation';
const { tabCounts, rootThread } = threadAnnotations(fakeThreadState);
assert.deepEqual(tabCounts, {
annotation: 0,
note: 0,
orphan: 0,
});
assert.equal(rootThread.children.length, 0);
});
['note', 'annotation', 'orphan'].forEach(selectedTab => { ['note', 'annotation', 'orphan'].forEach(selectedTab => {
it(`should filter the thread for the tab '${selectedTab}'`, () => { it(`should filter the thread for the tab '${selectedTab}'`, () => {
fakeThreadState.annotations = [ fakeThreadState.annotations = [
......
...@@ -80,14 +80,19 @@ function threadAnnotationsImpl( ...@@ -80,14 +80,19 @@ function threadAnnotationsImpl(
if (threadState.showTabs) { if (threadState.showTabs) {
rootThread.children = rootThread.children.filter(thread => { rootThread.children = rootThread.children.filter(thread => {
if (thread.annotation && isWaitingToAnchor(thread.annotation)) { // If the root annotation in this thread has been deleted, we don't know
// Until this annotation anchors or fails to anchor, we do not know which // which tab it used to be in.
// tab it should be displayed in. if (!thread.annotation) {
return false; return false;
} }
const tab = thread.annotation
? tabForAnnotation(thread.annotation) // If this annotation is still anchoring, we do not know whether it should
: 'annotation'; // appear in the "Annotations" or "Orphans" tab.
if (isWaitingToAnchor(thread.annotation)) {
return false;
}
const tab = tabForAnnotation(thread.annotation);
tabCounts[tab] += 1; tabCounts[tab] += 1;
return tab === selection.selectedTab; return tab === selection.selectedTab;
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment