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
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
e9d241f620
Коммит
14f1f4e9b1
@@ -40,7 +40,7 @@ export default class NewMessageIndicator extends React.Component {
|
|||||||
/>
|
/>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='posts_view.newMsgBelow'
|
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}}
|
values={{count: this.props.newMessages}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
|
||||||
import Post from './post.jsx';
|
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,
|
// Only count if we're not at the bottom, not in highlight view,
|
||||||
// or anything else
|
// or anything else
|
||||||
if (nextProps.scrollType === Constants.ScrollTypes.FREE) {
|
if (nextProps.scrollType === Constants.ScrollTypes.FREE) {
|
||||||
for (let i = order.length - 1; i >= 0; i--) {
|
unViewedCount = order.reduce((count, orderId) => {
|
||||||
const post = posts[order[i]];
|
const post = posts[orderId];
|
||||||
if (post.create_at > nextProps.lastViewedBottom &&
|
if (post.create_at > nextProps.lastViewedBottom &&
|
||||||
post.user_id !== nextProps.currentUser.id) {
|
post.user_id !== nextProps.currentUser.id &&
|
||||||
unViewedCount++;
|
post.state !== Constants.POST_DELETED) {
|
||||||
|
return count + 1;
|
||||||
}
|
}
|
||||||
}
|
return count;
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
this.setState({unViewedCount});
|
this.setState({unViewedCount});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1655,7 +1655,7 @@
|
|||||||
"post_info.reply": "Reply",
|
"post_info.reply": "Reply",
|
||||||
"posts_view.loadMore": "Load more messages",
|
"posts_view.loadMore": "Load more messages",
|
||||||
"posts_view.newMsg": "New 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.clickToAdd": "(click to add)",
|
||||||
"reaction.clickToRemove": "(click to remove)",
|
"reaction.clickToRemove": "(click to remove)",
|
||||||
"reaction.othersReacted": "{otherUsers, number} {otherUsers, plural, one {user} other {users}}",
|
"reaction.othersReacted": "{otherUsers, number} {otherUsers, plural, one {user} other {users}}",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user