Commit 7e9a65e5 authored by Robert Knight's avatar Robert Knight

Take into account the forced-visible set when filtering threads

When filtering annotations the `forcedVisible` list was taken into account, but
not when filtering threads. Consult this list when filtering threads as well.

This fixes an issue where newly created annotations would not be shown if they
did not match a thread filter. Note that newly added annotations are added to
the forced-visible set by the `ThreadList` component.
parent 3c90f0c0
...@@ -317,7 +317,13 @@ export function buildThread( ...@@ -317,7 +317,13 @@ export function buildThread(
}); });
} else if (options.threadFilterFn) { } else if (options.threadFilterFn) {
// Remove threads not matching thread-level filters // Remove threads not matching thread-level filters
thread.children = thread.children.filter(options.threadFilterFn); const threadFilterFn = options.threadFilterFn;
thread.children = thread.children.filter(thread => {
if (hasForcedVisible && options.forcedVisible.includes(thread.id)) {
return true;
}
return threadFilterFn(thread);
});
} }
// Set visibility for threads. // Set visibility for threads.
......
...@@ -475,11 +475,17 @@ describe('sidebar/helpers/build-thread', () => { ...@@ -475,11 +475,17 @@ describe('sidebar/helpers/build-thread', () => {
text: 'note', text: 'note',
target: [{ selector: undefined }], target: [{ selector: undefined }],
}, },
{
id: '3',
text: 'annotation',
target: [{ selector: undefined }],
},
]; ];
it('shows only annotations matching the thread filter', () => { it('shows only annotations matching the thread filter and forced-visible threads', () => {
const thread = createThread(fixture, { const thread = createThread(fixture, {
threadFilterFn: thread => metadata.isPageNote(thread.annotation), threadFilterFn: thread => metadata.isPageNote(thread.annotation),
forcedVisible: ['3'],
}); });
assert.deepEqual(thread, [ assert.deepEqual(thread, [
...@@ -487,6 +493,10 @@ describe('sidebar/helpers/build-thread', () => { ...@@ -487,6 +493,10 @@ describe('sidebar/helpers/build-thread', () => {
annotation: fixture[1], annotation: fixture[1],
children: [], children: [],
}, },
{
annotation: fixture[2],
children: [],
},
]); ]);
}); });
}); });
......
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