Commit dcf59584 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Get rid of duplicative actionCreator `clearSelectedAnnotations`

`clearSelection` does the same thing
parent a46fe918
...@@ -100,14 +100,14 @@ function SelectionTabs({ isLoading, settings }) { ...@@ -100,14 +100,14 @@ function SelectionTabs({ isLoading, settings }) {
); );
// actions // actions
const store = useStore(store => ({ const store = useStore(store => ({
clearSelectedAnnotations: store.clearSelectedAnnotations, clearSelection: store.clearSelection,
selectTab: store.selectTab, selectTab: store.selectTab,
})); }));
const isThemeClean = settings.theme === 'clean'; const isThemeClean = settings.theme === 'clean';
const selectTab = tabId => { const selectTab = tabId => {
store.clearSelectedAnnotations(); store.clearSelection();
store.selectTab(tabId); store.selectTab(tabId);
}; };
......
...@@ -60,9 +60,7 @@ function SidebarContent({ ...@@ -60,9 +60,7 @@ function SidebarContent({
: null; : null;
// Actions // Actions
const clearSelectedAnnotations = useStore( const clearSelection = useStore(store => store.clearSelection);
store => store.clearSelectedAnnotations
);
const selectTab = useStore(store => store.selectTab); const selectTab = useStore(store => store.selectTab);
// If, after loading completes, no `linkedAnnotation` object is present when // If, after loading completes, no `linkedAnnotation` object is present when
...@@ -96,14 +94,14 @@ function SidebarContent({ ...@@ -96,14 +94,14 @@ function SidebarContent({
useEffect(() => { useEffect(() => {
if (!prevGroupId.current || prevGroupId.current !== focusedGroupId) { if (!prevGroupId.current || prevGroupId.current !== focusedGroupId) {
// Clear any selected annotations when the group ID changes // Clear any selected annotations when the group ID changes
clearSelectedAnnotations(); clearSelection();
prevGroupId.current = focusedGroupId; prevGroupId.current = focusedGroupId;
} }
if (focusedGroupId && searchUris.length) { if (focusedGroupId && searchUris.length) {
loadAnnotationsService.load(searchUris, focusedGroupId); loadAnnotationsService.load(searchUris, focusedGroupId);
} }
}, [ }, [
clearSelectedAnnotations, clearSelection,
loadAnnotationsService, loadAnnotationsService,
focusedGroupId, focusedGroupId,
userId, userId,
......
...@@ -37,7 +37,6 @@ describe('HypothesisApp', () => { ...@@ -37,7 +37,6 @@ describe('HypothesisApp', () => {
fakeShouldAutoDisplayTutorial = sinon.stub().returns(false); fakeShouldAutoDisplayTutorial = sinon.stub().returns(false);
fakeStore = { fakeStore = {
clearSelectedAnnotations: sinon.spy(),
clearGroups: sinon.stub(), clearGroups: sinon.stub(),
closeSidebarPanel: sinon.stub(), closeSidebarPanel: sinon.stub(),
openSidebarPanel: sinon.stub(), openSidebarPanel: sinon.stub(),
......
...@@ -29,7 +29,7 @@ describe('SelectionTabs', function () { ...@@ -29,7 +29,7 @@ describe('SelectionTabs', function () {
enableExperimentalNewNoteButton: false, enableExperimentalNewNoteButton: false,
}; };
fakeStore = { fakeStore = {
clearSelectedAnnotations: sinon.stub(), clearSelection: sinon.stub(),
selectTab: sinon.stub(), selectTab: sinon.stub(),
annotationCount: sinon.stub().returns(123), annotationCount: sinon.stub().returns(123),
noteCount: sinon.stub().returns(456), noteCount: sinon.stub().returns(456),
...@@ -245,7 +245,7 @@ describe('SelectionTabs', function () { ...@@ -245,7 +245,7 @@ describe('SelectionTabs', function () {
findButton(wrapper, label).simulate('click'); findButton(wrapper, label).simulate('click');
assert.calledOnce(fakeStore.clearSelectedAnnotations); assert.calledOnce(fakeStore.clearSelection);
assert.calledWith(fakeStore.selectTab, tab); assert.calledWith(fakeStore.selectTab, tab);
}); });
}); });
...@@ -260,7 +260,7 @@ describe('SelectionTabs', function () { ...@@ -260,7 +260,7 @@ describe('SelectionTabs', function () {
findButton(wrapper, 'Page Notes').simulate('click'); findButton(wrapper, 'Page Notes').simulate('click');
assert.notCalled(fakeStore.clearSelectedAnnotations); assert.notCalled(fakeStore.clearSelection);
assert.notCalled(fakeStore.selectTab); assert.notCalled(fakeStore.selectTab);
}); });
......
...@@ -41,7 +41,7 @@ describe('SidebarContent', () => { ...@@ -41,7 +41,7 @@ describe('SidebarContent', () => {
}; };
fakeStore = { fakeStore = {
// actions // actions
clearSelectedAnnotations: sinon.stub(), clearSelection: sinon.stub(),
selectTab: sinon.stub(), selectTab: sinon.stub(),
// selectors // selectors
annotationExists: sinon.stub(), annotationExists: sinon.stub(),
...@@ -91,21 +91,21 @@ describe('SidebarContent', () => { ...@@ -91,21 +91,21 @@ describe('SidebarContent', () => {
fakeStore.profile.returns({ userid: 'somethingElse' }); fakeStore.profile.returns({ userid: 'somethingElse' });
wrapper.setProps({}); wrapper.setProps({});
assert.calledOnce(fakeLoadAnnotationsService.load); assert.calledOnce(fakeLoadAnnotationsService.load);
assert.notCalled(fakeStore.clearSelectedAnnotations); assert.notCalled(fakeStore.clearSelection);
}); });
it('clears selected annotations and loads annotations when groupId changes', () => { it('clears selected annotations and loads annotations when groupId changes', () => {
fakeStore.focusedGroupId.returns('affable'); fakeStore.focusedGroupId.returns('affable');
wrapper.setProps({}); wrapper.setProps({});
assert.calledOnce(fakeLoadAnnotationsService.load); assert.calledOnce(fakeLoadAnnotationsService.load);
assert.calledOnce(fakeStore.clearSelectedAnnotations); assert.calledOnce(fakeStore.clearSelection);
}); });
it('loads annotations when searchURIs change', () => { it('loads annotations when searchURIs change', () => {
fakeStore.searchUris.returns(['abandon-ship']); fakeStore.searchUris.returns(['abandon-ship']);
wrapper.setProps({}); wrapper.setProps({});
assert.calledOnce(fakeLoadAnnotationsService.load); assert.calledOnce(fakeLoadAnnotationsService.load);
assert.notCalled(fakeStore.clearSelectedAnnotations); assert.notCalled(fakeStore.clearSelection);
}); });
}); });
......
...@@ -193,10 +193,6 @@ const update = { ...@@ -193,10 +193,6 @@ const update = {
}; };
}, },
CLEAR_SELECTED_ANNOTATIONS: function () {
return resetSelection();
},
CLEAR_SELECTION: function () { CLEAR_SELECTION: function () {
return resetSelection(); return resetSelection();
}, },
...@@ -306,11 +302,10 @@ function changeFocusModeUser(user) { ...@@ -306,11 +302,10 @@ function changeFocusModeUser(user) {
return { type: actions.CHANGE_FOCUS_MODE_USER, user }; return { type: actions.CHANGE_FOCUS_MODE_USER, user };
} }
/** De-select all annotations. */ /**
function clearSelectedAnnotations() { * Clear all selected annotations and filters. This will leave user-focus
return { type: actions.CLEAR_SELECTED_ANNOTATIONS }; * alone, however.
} */
function clearSelection() { function clearSelection() {
return { return {
type: actions.CLEAR_SELECTION, type: actions.CLEAR_SELECTION,
...@@ -602,7 +597,6 @@ const threadState = createSelector( ...@@ -602,7 +597,6 @@ const threadState = createSelector(
* *
* // Actions * // Actions
* @prop {typeof changeFocusModeUser} changeFocusModeUser * @prop {typeof changeFocusModeUser} changeFocusModeUser
* @prop {typeof clearSelectedAnnotations} clearSelectedAnnotations
* @prop {typeof clearSelection} clearSelection * @prop {typeof clearSelection} clearSelection
* @prop {typeof selectAnnotations} selectAnnotations * @prop {typeof selectAnnotations} selectAnnotations
* @prop {typeof selectTab} selectTab * @prop {typeof selectTab} selectTab
...@@ -639,7 +633,6 @@ export default { ...@@ -639,7 +633,6 @@ export default {
actions: { actions: {
changeFocusModeUser, changeFocusModeUser,
clearSelectedAnnotations,
clearSelection, clearSelection,
selectAnnotations, selectAnnotations,
selectTab, selectTab,
......
...@@ -279,20 +279,6 @@ describe('sidebar/store/modules/selection', () => { ...@@ -279,20 +279,6 @@ describe('sidebar/store/modules/selection', () => {
}); });
}); });
describe('clearSelectedAnnotations()', function () {
it('removes all annotations from the selection', function () {
store.selectAnnotations([1]);
store.clearSelectedAnnotations();
assert.isEmpty(getSelectionState().selected);
});
it('clears the current search query', function () {
store.setFilterQuery('foo');
store.clearSelectedAnnotations();
assert.isNull(getSelectionState().filterQuery);
});
});
describe('setFilterQuery()', function () { describe('setFilterQuery()', function () {
it('sets the filter query', function () { it('sets the filter query', function () {
store.setFilterQuery('a-query'); store.setFilterQuery('a-query');
......
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