update session when user gets muted

This commit is contained in:
seotts 2021-06-07 16:35:44 -04:00
parent 7e1eb3a2f8
commit 3d6a789812
2 changed files with 15 additions and 1 deletions

View file

@ -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);

View file

@ -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,