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