From 37131df008f5ee09dc5ad9cb43b56968e64b743d Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Tue, 3 Oct 2017 12:53:49 -0400 Subject: [PATCH] Handle message count split in container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue where admin messages caused social messages to display as unread when they weren’t --- src/views/messages/container.jsx | 13 +++++++++++-- src/views/messages/presentation.jsx | 15 ++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/views/messages/container.jsx b/src/views/messages/container.jsx index 0fd9a1b96..c1cbceb90 100644 --- a/src/views/messages/container.jsx +++ b/src/views/messages/container.jsx @@ -145,10 +145,18 @@ var Messages = React.createClass({ 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( this.props.messages, this.state.filterValues, - this.props.numNewMessages + numNewSocialMessages ); return( @@ -158,7 +166,8 @@ var Messages = React.createClass({ messages={messages} adminMessages={this.props.adminMessages} scratcherInvite={this.props.invite} - numNewMessages={this.props.numNewMessages} + numNewMessages={numNewSocialMessages} + adminMessagesLength={adminMessagesLength} handleFilterClick={this.handleFilterClick} handleAdminDismiss={this.handleMessageDismiss} loadMore={loadMore} diff --git a/src/views/messages/presentation.jsx b/src/views/messages/presentation.jsx index 5043b3011..1cc805f1e 100644 --- a/src/views/messages/presentation.jsx +++ b/src/views/messages/presentation.jsx @@ -209,6 +209,7 @@ var MessagesPresentation = injectIntl(React.createClass({ adminMessages: React.PropTypes.array.isRequired, scratcherInvite: React.PropTypes.object.isRequired, numNewMessages: React.PropTypes.number, + adminMessagesLength: React.PropTypes.number, handleFilterClick: React.PropTypes.func.isRequired, handleAdminDismiss: React.PropTypes.func.isRequired, loadMore: React.PropTypes.bool.isRequired, @@ -218,19 +219,11 @@ var MessagesPresentation = injectIntl(React.createClass({ getDefaultProps: function () { return { numNewMessages: 0, + adminMessagesLength: 0, filterOpen: false }; }, 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 (
@@ -278,7 +271,7 @@ var MessagesPresentation = injectIntl(React.createClass({

- +

@@ -318,7 +311,7 @@ var MessagesPresentation = injectIntl(React.createClass({