diff options
author | Pepijn <pepijnfens@gmail.com> | 2016-12-28 03:49:44 +0100 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-12-27 21:49:44 -0500 |
commit | 14f1f4e9b119f00246a7a5f49e607413c99e4f74 (patch) | |
tree | 17f49c578b9476eb6e6d6737a038731fd4621a07 /webapp | |
parent | e9d241f62049dccec446b91097e7f5831bb235fa (diff) | |
download | chat-14f1f4e9b119f00246a7a5f49e607413c99e4f74.tar.gz chat-14f1f4e9b119f00246a7a5f49e607413c99e4f74.tar.bz2 chat-14f1f4e9b119f00246a7a5f49e607413c99e4f74.zip |
Tweaked new message indicator calculation: (#4763)
* Removed count from new message indicator
* Don't count deleted posts towards the unviewedCount
* remove lodash, reduce() is natively available
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/components/post_view/components/new_message_indicator.jsx | 2 | ||||
-rw-r--r-- | webapp/components/post_view/components/post_list.jsx | 13 | ||||
-rw-r--r-- | webapp/i18n/en.json | 2 |
3 files changed, 9 insertions, 8 deletions
diff --git a/webapp/components/post_view/components/new_message_indicator.jsx b/webapp/components/post_view/components/new_message_indicator.jsx index f9bd17bd7..5167a3d2d 100644 --- a/webapp/components/post_view/components/new_message_indicator.jsx +++ b/webapp/components/post_view/components/new_message_indicator.jsx @@ -40,7 +40,7 @@ export default class NewMessageIndicator extends React.Component { /> <FormattedMessage id='posts_view.newMsgBelow' - defaultMessage='{count} new {count, plural, one {message} other {messages}} below' + defaultMessage='New {count, plural, one {message} other {messages}} below' values={{count: this.props.newMessages}} /> </div> diff --git a/webapp/components/post_view/components/post_list.jsx b/webapp/components/post_view/components/post_list.jsx index 05e2ff618..516487eaf 100644 --- a/webapp/components/post_view/components/post_list.jsx +++ b/webapp/components/post_view/components/post_list.jsx @@ -1,6 +1,5 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. - import $ from 'jquery'; import Post from './post.jsx'; @@ -84,13 +83,15 @@ export default class PostList extends React.Component { // Only count if we're not at the bottom, not in highlight view, // or anything else if (nextProps.scrollType === Constants.ScrollTypes.FREE) { - for (let i = order.length - 1; i >= 0; i--) { - const post = posts[order[i]]; + unViewedCount = order.reduce((count, orderId) => { + const post = posts[orderId]; if (post.create_at > nextProps.lastViewedBottom && - post.user_id !== nextProps.currentUser.id) { - unViewedCount++; + post.user_id !== nextProps.currentUser.id && + post.state !== Constants.POST_DELETED) { + return count + 1; } - } + return count; + }, 0); } this.setState({unViewedCount}); } diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index e194da64e..e8ea8ab14 100644 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -1655,7 +1655,7 @@ "post_info.reply": "Reply", "posts_view.loadMore": "Load more messages", "posts_view.newMsg": "New Messages", - "posts_view.newMsgBelow": "{count} new {count, plural, one {message} other {messages}} below", + "posts_view.newMsgBelow": "New {count, plural, one {message} other {messages}} below", "reaction.clickToAdd": "(click to add)", "reaction.clickToRemove": "(click to remove)", "reaction.othersReacted": "{otherUsers, number} {otherUsers, plural, one {user} other {users}}", |