Fix GH-[1505, 1507]: hide message counter on 0 (#1510)

* Hide messages counter when at 0

fixes #1507

* check for body before looking at success

fixes #1505
This commit is contained in:
Matthew Taylor 2017-09-06 10:05:14 -04:00 committed by GitHub
parent b77e278927
commit 2bd9b184c5
2 changed files with 10 additions and 4 deletions

View file

@ -130,7 +130,7 @@ module.exports.clearMessageCount = function () {
dispatch(module.exports.setMessagesError(err));
return;
}
if (!body.success) {
if (typeof body !== 'undefined' && !body.success) {
dispatch(module.exports.setStatus('CLEAR_STATUS', module.exports.Status.CLEAR_ERROR));
dispatch(module.exports.setMessagesError('messages not cleared'));
return;

View file

@ -163,6 +163,14 @@ var SocialMessagesList = React.createClass({
}
return null;
},
renderMessageCounter: function (numNewMessages) {
if (numNewMessages > 0) {
return <div className="messages-header-unread">
<FormattedNumber value={numNewMessages} />
</div>;
}
return null;
},
render: function () {
if (this.props.loadStatus === messageStatuses.MESSAGES_ERROR) {
return (
@ -183,9 +191,7 @@ var SocialMessagesList = React.createClass({
<div className="messages-social-title" key="messages-social-title">
<h4 className="messages-header">
<FormattedMessage id='messages.messageTitle' />
<div className="messages-header-unread">
<FormattedNumber value={this.props.numNewMessages} />
</div>
{this.renderMessageCounter(this.props.numNewMessages)}
</h4>
</div>,
<ul className="messages-social-list" key="messages-social-list">