Commit 71b93cb2 authored by Matthew Taylor's avatar Matthew Taylor

reduce unread count on successful admin message dismiss

parent 630ae5e4
......@@ -3,6 +3,7 @@ var keyMirror = require('keymirror');
var api = require('../lib/api');
var log = require('../lib/log');
var messageCountActions = require('./message-count.js');
module.exports.Status = keyMirror({
FETCHED: null,
......@@ -135,7 +136,7 @@ module.exports.clearMessageCount = function () {
};
};
module.exports.clearAdminMessage = function (messageType, messageId, adminMessages) {
module.exports.clearAdminMessage = function (messageType, messageId, messageCount, adminMessages) {
return function (dispatch) {
dispatch(module.exports.setStatus('CLEAR_STATUS', module.exports.Status.FETCHING));
api({
......@@ -156,6 +157,7 @@ module.exports.clearAdminMessage = function (messageType, messageId, adminMessag
if (!body.success) {
dispatch(module.exports.setStatus('DELETE_STATUS', module.exports.Status.DELETE_ERROR));
dispatch(module.exports.setMessagesError('messages not cleared'));
return;
}
if (messageType === 'invite') {
......@@ -173,6 +175,7 @@ module.exports.clearAdminMessage = function (messageType, messageId, adminMessag
adminMessages.splice(toRemove, 1);
dispatch(module.exports.setAdminMessages(adminMessages));
}
dispatch(messageCountActions.setCount(messageCount - 1));
dispatch(module.exports.setStatus('DELETE_STATUS', module.exports.Status.FETCHED));
});
};
......
......@@ -95,7 +95,9 @@ var Messages = React.createClass({
adminMessages = this.props.adminMessages;
}
this.props.dispatch(
messageActions.clearAdminMessage(messageType, messageId, adminMessages)
messageActions.clearAdminMessage(
messageType, messageId, this.props.numNewMessages, adminMessages
)
);
},
handleLoadMoreMessages: function () {
......
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