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