mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Merge pull request #191 from mewtaylor/issue/95-message-notification-persists
WIP #95 – Reset `unreadMessageCount` state
This commit is contained in:
commit
a44894be6d
1 changed files with 10 additions and 3 deletions
|
@ -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));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue