Merge pull request #191 from mewtaylor/issue/95-message-notification-persists

WIP #95 – Reset `unreadMessageCount` state
This commit is contained in:
Matthew Taylor 2015-11-03 09:48:57 -05:00
commit a44894be6d

View file

@ -72,7 +72,10 @@ var Navigation = React.createClass({
} else { } else {
// clear message count check, and set to default id. // clear message count check, and set to default id.
clearInterval(this.state.messageCountIntervalId); clearInterval(this.state.messageCountIntervalId);
this.setState({'messageCountIntervalId': -1}); this.setState({
'unreadMessageCount': 0,
'messageCountIntervalId': -1
});
} }
} }
}, },
@ -80,7 +83,10 @@ var Navigation = React.createClass({
// clear message interval if it exists // clear message interval if it exists
if (this.state.messageCountIntervalId != -1) { if (this.state.messageCountIntervalId != -1) {
clearInterval(this.state.messageCountIntervalId); clearInterval(this.state.messageCountIntervalId);
this.setState({'messageCountIntervalId': -1}); this.setState({
'unreadMessageCount': 0,
'messageCountIntervalId': -1
});
} }
}, },
getProfileUrl: function () { getProfileUrl: function () {
@ -92,9 +98,10 @@ var Navigation = React.createClass({
method: 'get', method: 'get',
uri: '/proxy/users/' + this.state.session.user.username + '/activity/count' uri: '/proxy/users/' + this.state.session.user.username + '/activity/count'
}, function (err, body) { }, function (err, body) {
if (err) return this.setState({'unreadMessageCount': 0});
if (body) { if (body) {
var count = parseInt(body.msg_count, this.state.unreadMessageCount); var count = parseInt(body.msg_count, this.state.unreadMessageCount);
this.setState({'unreadMessageCount': count}); return this.setState({'unreadMessageCount': count});
} }
}.bind(this)); }.bind(this));
}, },