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