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