Commit 37131df0 authored by Matthew Taylor's avatar Matthew Taylor

Handle message count split in container

Fixes issue where admin messages caused social messages to display as unread when they weren’t
parent d272a2e4
...@@ -145,10 +145,18 @@ var Messages = React.createClass({ ...@@ -145,10 +145,18 @@ var Messages = React.createClass({
loadMore = false; loadMore = false;
} }
var adminMessagesLength = this.props.adminMessages.length;
if (Object.keys(this.props.invite).length > 0) {
adminMessagesLength = adminMessagesLength + 1;
}
var numNewSocialMessages = this.props.numNewMessages - adminMessagesLength;
if (numNewSocialMessages < 0) {
numNewSocialMessages = 0;
}
var messages = this.filterMessages( var messages = this.filterMessages(
this.props.messages, this.props.messages,
this.state.filterValues, this.state.filterValues,
this.props.numNewMessages numNewSocialMessages
); );
return( return(
...@@ -158,7 +166,8 @@ var Messages = React.createClass({ ...@@ -158,7 +166,8 @@ var Messages = React.createClass({
messages={messages} messages={messages}
adminMessages={this.props.adminMessages} adminMessages={this.props.adminMessages}
scratcherInvite={this.props.invite} scratcherInvite={this.props.invite}
numNewMessages={this.props.numNewMessages} numNewMessages={numNewSocialMessages}
adminMessagesLength={adminMessagesLength}
handleFilterClick={this.handleFilterClick} handleFilterClick={this.handleFilterClick}
handleAdminDismiss={this.handleMessageDismiss} handleAdminDismiss={this.handleMessageDismiss}
loadMore={loadMore} loadMore={loadMore}
......
...@@ -209,6 +209,7 @@ var MessagesPresentation = injectIntl(React.createClass({ ...@@ -209,6 +209,7 @@ var MessagesPresentation = injectIntl(React.createClass({
adminMessages: React.PropTypes.array.isRequired, adminMessages: React.PropTypes.array.isRequired,
scratcherInvite: React.PropTypes.object.isRequired, scratcherInvite: React.PropTypes.object.isRequired,
numNewMessages: React.PropTypes.number, numNewMessages: React.PropTypes.number,
adminMessagesLength: React.PropTypes.number,
handleFilterClick: React.PropTypes.func.isRequired, handleFilterClick: React.PropTypes.func.isRequired,
handleAdminDismiss: React.PropTypes.func.isRequired, handleAdminDismiss: React.PropTypes.func.isRequired,
loadMore: React.PropTypes.bool.isRequired, loadMore: React.PropTypes.bool.isRequired,
...@@ -218,19 +219,11 @@ var MessagesPresentation = injectIntl(React.createClass({ ...@@ -218,19 +219,11 @@ var MessagesPresentation = injectIntl(React.createClass({
getDefaultProps: function () { getDefaultProps: function () {
return { return {
numNewMessages: 0, numNewMessages: 0,
adminMessagesLength: 0,
filterOpen: false filterOpen: false
}; };
}, },
render: function () { render: function () {
var adminMessageLength = this.props.adminMessages.length;
if (Object.keys(this.props.scratcherInvite).length > 0) {
adminMessageLength = adminMessageLength + 1;
}
var numNewSocialMessages = this.props.numNewMessages - adminMessageLength;
if (numNewSocialMessages < 0) {
numNewSocialMessages = 0;
}
return ( return (
<div className="messages"> <div className="messages">
<TitleBanner className="mod-messages"> <TitleBanner className="mod-messages">
...@@ -278,7 +271,7 @@ var MessagesPresentation = injectIntl(React.createClass({ ...@@ -278,7 +271,7 @@ var MessagesPresentation = injectIntl(React.createClass({
<h4 className="messages-header"> <h4 className="messages-header">
<FormattedMessage id='messages.scratchTeamTitle' /> <FormattedMessage id='messages.scratchTeamTitle' />
<div className="messages-header-unread"> <div className="messages-header-unread">
<FormattedNumber value={adminMessageLength} /> <FormattedNumber value={this.props.adminMessagesLength} />
</div> </div>
</h4> </h4>
</div> </div>
...@@ -318,7 +311,7 @@ var MessagesPresentation = injectIntl(React.createClass({ ...@@ -318,7 +311,7 @@ var MessagesPresentation = injectIntl(React.createClass({
<SocialMessagesList <SocialMessagesList
loadStatus={this.props.requestStatus.messages} loadStatus={this.props.requestStatus.messages}
messages={this.props.messages} messages={this.props.messages}
numNewMessages={numNewSocialMessages} numNewMessages={this.props.numNewMessages}
loadMore={this.props.loadMore} loadMore={this.props.loadMore}
loadMoreMethod={this.props.loadMoreMethod} loadMoreMethod={this.props.loadMoreMethod}
/> />
......
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