Commit 2bd9b184 authored by Matthew Taylor's avatar Matthew Taylor Committed by GitHub

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
parent b77e2789
......@@ -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;
......
......@@ -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">
......
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