mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
reduce unread count on successful admin message dismiss
This commit is contained in:
parent
630ae5e462
commit
71b93cb207
2 changed files with 7 additions and 2 deletions
|
@ -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 () {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
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({
|
||||||
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 () {
|
||||||
|
|
Loading…
Reference in a new issue