Unverified Commit a1178f7a authored by Sarah Otts's avatar Sarah Otts Committed by GitHub

Merge pull request #5567 from seotts/muted-update-session

When a user gets muted, update mute status in the session
parents 7cbff4bd 3d6a7898
......@@ -121,6 +121,18 @@ module.exports.refreshSessionWithRetry = () => (dispatch => {
});
});
module.exports.updateMuteStatus = muteStatus => ((dispatch, getState) => {
const session = getState().session.session;
const newSession = {
...session,
permissions: {
...session.permissions,
mute_status: muteStatus
}
};
dispatch(module.exports.setSession(newSession));
});
// Selectors
module.exports.selectIsLoggedIn = state => !!get(state, ['session', 'session', 'user'], false);
module.exports.selectUsername = state => get(state, ['session', 'session', 'user', 'username'], null);
......
......@@ -17,7 +17,7 @@ const formatTime = require('../../../lib/format-time');
const connect = require('react-redux').connect;
const api = require('../../../lib/api');
const {selectMuteStatus} = require('../../../redux/session.js');
const {selectMuteStatus, updateMuteStatus} = require('../../../redux/session.js');
require('./comment.scss');
......@@ -118,6 +118,7 @@ class ComposeComment extends React.Component {
showWarning = body.status.mute_status.showWarning;
muteType = body.status.mute_status.currentMessageType;
this.setupMuteExpirationTimeout(muteExpiresAtMs);
this.props.dispatch(updateMuteStatus(body.status.mute_status));
}
// Note: does not reset the message state
this.setState({
......@@ -425,6 +426,7 @@ class ComposeComment extends React.Component {
ComposeComment.propTypes = {
commenteeId: PropTypes.number,
dispatch: PropTypes.func,
isReply: PropTypes.bool,
muteStatus: PropTypes.shape({
offenses: PropTypes.array,
......
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