Commit c9002b9c authored by Lyza Danger Gardner's avatar Lyza Danger Gardner

Add selector for retrieving `expandedThreads`

parent 35fdf55e
......@@ -89,7 +89,7 @@ export default function RootThread(
// determines what is visible and build the visible thread structure
return buildThread(state.annotations.annotations, {
forceVisible: truthyKeys(state.selection.forceVisible),
expanded: state.selection.expanded,
expanded: store.expandedThreads(),
highlighted: state.selection.highlighted,
selected: truthyKeys(store.getSelectedAnnotationMap() || {}),
sortCompareFn: sortFn,
......
......@@ -46,7 +46,6 @@ describe('rootThread', function () {
},
drafts: [],
selection: {
expanded: {},
filterQuery: null,
forceVisible: {},
highlighted: [],
......@@ -62,6 +61,7 @@ describe('rootThread', function () {
return this.state;
},
expandedThreads: sinon.stub().returns({}),
getSelectedAnnotationMap: sinon.stub().returns(null),
subscribe: sinon.stub(),
removeAnnotations: sinon.stub(),
......@@ -143,7 +143,7 @@ describe('rootThread', function () {
});
it('passes the current expanded set to buildThread()', function () {
fakeStore.state.selection.expanded = { id1: true, id2: true };
fakeStore.expandedThreads.returns({ id1: true, id2: true });
rootThread.thread(fakeStore.state);
assert.calledWith(
fakeBuildThread,
......
......@@ -430,6 +430,10 @@ const getFirstSelectedAnnotationId = createSelector(
selected => (selected ? Object.keys(selected)[0] : null)
);
function expandedThreads(state) {
return state.selection.expanded;
}
function filterQuery(state) {
return state.selection.filterQuery;
}
......@@ -531,6 +535,7 @@ export default {
selectors: {
hasSelectedAnnotations,
expandedThreads,
filterQuery,
focusModeFocused,
focusModeEnabled,
......
......@@ -38,7 +38,7 @@ describe('sidebar/store/modules/selection', () => {
describe('setCollapsed()', function () {
it('sets the expanded state of the annotation', function () {
store.setCollapsed('parent_id', false);
assert.deepEqual(getSelectionState().expanded, { parent_id: true });
assert.deepEqual(store.expandedThreads(), { parent_id: true });
});
});
......
......@@ -37,7 +37,7 @@ describe('store', function () {
describe('initialization', function () {
it('does not set a selection when settings.annotations is null', function () {
assert.isFalse(store.hasSelectedAnnotations());
assert.equal(Object.keys(store.getState().selection.expanded).length, 0);
assert.equal(Object.keys(store.expandedThreads()).length, 0);
});
it('sets the selection when settings.annotations is set', function () {
......@@ -49,7 +49,7 @@ describe('store', function () {
it('expands the selected annotations when settings.annotations is set', function () {
store = storeFactory(fakeRootScope, { annotations: 'testid' });
assert.deepEqual(store.getState().selection.expanded, {
assert.deepEqual(store.expandedThreads(), {
testid: true,
});
});
......
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