Commit 4f25a2ae authored by seotts's avatar seotts

Don’t show errors for toggling openToAll or commentsAllowed

parent 91d66cd2
...@@ -90,9 +90,7 @@ const selectFollowingMutationError = state => state.studioMutations.mutationErro ...@@ -90,9 +90,7 @@ const selectFollowingMutationError = state => state.studioMutations.mutationErro
const selectIsMutatingImage = state => state.studioMutations.isMutating.image; const selectIsMutatingImage = state => state.studioMutations.isMutating.image;
const selectImageMutationError = state => state.studioMutations.mutationErrors.image; const selectImageMutationError = state => state.studioMutations.mutationErrors.image;
const selectIsMutatingOpenToAll = state => state.studioMutations.isMutating.openToAll; const selectIsMutatingOpenToAll = state => state.studioMutations.isMutating.openToAll;
const selectOpenToAllMutationError = state => state.studioMutations.mutationErrors.openToAll;
const selectIsMutatingCommentsAllowed = state => state.studioMutations.isMutating.commentsAllowed; const selectIsMutatingCommentsAllowed = state => state.studioMutations.isMutating.commentsAllowed;
const selectCommentsAllowedMutationError = state => state.studioMutations.mutationErrors.commentsAllowed;
// Thunks // Thunks
/** /**
...@@ -223,6 +221,8 @@ const mutateStudioCommentsAllowed = shouldAllow => ((dispatch, getState) => { ...@@ -223,6 +221,8 @@ const mutateStudioCommentsAllowed = shouldAllow => ((dispatch, getState) => {
}, (err, body, res) => { }, (err, body, res) => {
const error = normalizeError(err, body, res); const error = normalizeError(err, body, res);
const wasAllowed = selectStudioCommentsAllowed(state); const wasAllowed = selectStudioCommentsAllowed(state);
// eslint-disable-next-line no-console
console.error(`Error mutating commentsAllowed: ${error}`);
dispatch(completeMutation('commentsAllowed', error ? wasAllowed : shouldAllow, error)); dispatch(completeMutation('commentsAllowed', error ? wasAllowed : shouldAllow, error));
}); });
}); });
...@@ -239,6 +239,8 @@ const mutateStudioOpenToAll = shouldBeOpen => ((dispatch, getState) => { ...@@ -239,6 +239,8 @@ const mutateStudioOpenToAll = shouldBeOpen => ((dispatch, getState) => {
}, (err, body, res) => { }, (err, body, res) => {
const error = normalizeError(err, body, res); const error = normalizeError(err, body, res);
const wasOpen = selectStudioOpenToAll(getState()); const wasOpen = selectStudioOpenToAll(getState());
// eslint-disable-next-line no-console
console.error(`Error mutating openToAll: ${error}`);
dispatch(completeMutation('openToAll', error ? wasOpen : shouldBeOpen, error)); dispatch(completeMutation('openToAll', error ? wasOpen : shouldBeOpen, error));
}); });
}); });
...@@ -266,7 +268,5 @@ module.exports = { ...@@ -266,7 +268,5 @@ module.exports = {
selectIsMutatingImage, selectIsMutatingImage,
selectImageMutationError, selectImageMutationError,
selectIsMutatingCommentsAllowed, selectIsMutatingCommentsAllowed,
selectCommentsAllowedMutationError, selectIsMutatingOpenToAll
selectIsMutatingOpenToAll,
selectOpenToAllMutationError
}; };
...@@ -7,13 +7,13 @@ import classNames from 'classnames'; ...@@ -7,13 +7,13 @@ import classNames from 'classnames';
import {selectStudioCommentsAllowed, selectIsFetchingInfo} from '../../redux/studio'; import {selectStudioCommentsAllowed, selectIsFetchingInfo} from '../../redux/studio';
import { import {
mutateStudioCommentsAllowed, selectIsMutatingCommentsAllowed, selectCommentsAllowedMutationError mutateStudioCommentsAllowed, selectIsMutatingCommentsAllowed
} from '../../redux/studio-mutations'; } from '../../redux/studio-mutations';
import ToggleSlider from '../../components/forms/toggle-slider.jsx'; import ToggleSlider from '../../components/forms/toggle-slider.jsx';
const StudioCommentsAllowed = ({ const StudioCommentsAllowed = ({
commentsAllowedError, isFetching, isMutating, commentsAllowed, handleUpdate isFetching, isMutating, commentsAllowed, handleUpdate
}) => ( }) => (
<div> <div>
{isFetching ? ( {isFetching ? (
...@@ -33,14 +33,12 @@ const StudioCommentsAllowed = ({ ...@@ -33,14 +33,12 @@ const StudioCommentsAllowed = ({
})} })}
onChange={e => handleUpdate(e.target.checked)} onChange={e => handleUpdate(e.target.checked)}
/> />
{commentsAllowedError && <div>Error mutating commentsAllowed: {commentsAllowedError}</div>}
</div> </div>
)} )}
</div> </div>
); );
StudioCommentsAllowed.propTypes = { StudioCommentsAllowed.propTypes = {
commentsAllowedError: PropTypes.string,
isFetching: PropTypes.bool, isFetching: PropTypes.bool,
isMutating: PropTypes.bool, isMutating: PropTypes.bool,
commentsAllowed: PropTypes.bool, commentsAllowed: PropTypes.bool,
...@@ -51,8 +49,7 @@ export default connect( ...@@ -51,8 +49,7 @@ export default connect(
state => ({ state => ({
commentsAllowed: selectStudioCommentsAllowed(state), commentsAllowed: selectStudioCommentsAllowed(state),
isFetching: selectIsFetchingInfo(state), isFetching: selectIsFetchingInfo(state),
isMutating: selectIsMutatingCommentsAllowed(state), isMutating: selectIsMutatingCommentsAllowed(state)
commentsAllowedError: selectCommentsAllowedMutationError(state)
}), }),
{ {
handleUpdate: mutateStudioCommentsAllowed handleUpdate: mutateStudioCommentsAllowed
......
...@@ -7,13 +7,13 @@ import classNames from 'classnames'; ...@@ -7,13 +7,13 @@ import classNames from 'classnames';
import {selectStudioOpenToAll, selectIsFetchingInfo} from '../../redux/studio'; import {selectStudioOpenToAll, selectIsFetchingInfo} from '../../redux/studio';
import { import {
mutateStudioOpenToAll, selectIsMutatingOpenToAll, selectOpenToAllMutationError mutateStudioOpenToAll, selectIsMutatingOpenToAll
} from '../../redux/studio-mutations'; } from '../../redux/studio-mutations';
import ToggleSlider from '../../components/forms/toggle-slider.jsx'; import ToggleSlider from '../../components/forms/toggle-slider.jsx';
const StudioOpenToAll = ({ const StudioOpenToAll = ({
openToAllError, isFetching, isMutating, openToAll, handleUpdate isFetching, isMutating, openToAll, handleUpdate
}) => ( }) => (
<div> <div>
{isFetching ? ( {isFetching ? (
...@@ -29,14 +29,12 @@ const StudioOpenToAll = ({ ...@@ -29,14 +29,12 @@ const StudioOpenToAll = ({
})} })}
onChange={e => handleUpdate(e.target.checked)} onChange={e => handleUpdate(e.target.checked)}
/> />
{openToAllError && <div>Error mutating openToAll: {openToAllError}</div>}
</div> </div>
)} )}
</div> </div>
); );
StudioOpenToAll.propTypes = { StudioOpenToAll.propTypes = {
openToAllError: PropTypes.string,
isFetching: PropTypes.bool, isFetching: PropTypes.bool,
isMutating: PropTypes.bool, isMutating: PropTypes.bool,
openToAll: PropTypes.bool, openToAll: PropTypes.bool,
...@@ -47,8 +45,7 @@ export default connect( ...@@ -47,8 +45,7 @@ export default connect(
state => ({ state => ({
openToAll: selectStudioOpenToAll(state), openToAll: selectStudioOpenToAll(state),
isFetching: selectIsFetchingInfo(state), isFetching: selectIsFetchingInfo(state),
isMutating: selectIsMutatingOpenToAll(state), isMutating: selectIsMutatingOpenToAll(state)
openToAllError: selectOpenToAllMutationError(state)
}), }),
{ {
handleUpdate: mutateStudioOpenToAll handleUpdate: mutateStudioOpenToAll
......
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