mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-17 00:21:20 -05:00
Reset unreadMessageCount
state
1. When the component is unmounted 2. When the user's state changes to logged out I think this should fix any state-side issues with the persistence for #95.
This commit is contained in:
parent
d98dd56d7e
commit
b2d05a996f
1 changed files with 10 additions and 3 deletions
|
@ -68,7 +68,10 @@ var Navigation = React.createClass({
|
|||
} else {
|
||||
// clear message count check, and set to default id.
|
||||
clearInterval(this.state.messageCountIntervalId);
|
||||
this.setState({'messageCountIntervalId': -1});
|
||||
this.setState({
|
||||
'unreadMessageCount': 0,
|
||||
'messageCountIntervalId': -1
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -76,7 +79,10 @@ var Navigation = React.createClass({
|
|||
// clear message interval if it exists
|
||||
if (this.state.messageCountIntervalId != -1) {
|
||||
clearInterval(this.state.messageCountIntervalId);
|
||||
this.setState({'messageCountIntervalId': -1});
|
||||
this.setState({
|
||||
'unreadMessageCount': 0,
|
||||
'messageCountIntervalId': -1
|
||||
});
|
||||
}
|
||||
},
|
||||
getProfileUrl: function () {
|
||||
|
@ -88,9 +94,10 @@ var Navigation = React.createClass({
|
|||
method: 'get',
|
||||
uri: '/proxy/users/' + this.state.session.user.username + '/activity/count'
|
||||
}, function (err, body) {
|
||||
if (err) return this.setState({'unreadMessageCount': 0});
|
||||
if (body) {
|
||||
var count = parseInt(body.msg_count, this.state.unreadMessageCount);
|
||||
this.setState({'unreadMessageCount': count});
|
||||
return this.setState({'unreadMessageCount': count});
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue