ICU-653 Stopped filtering out join/leave messages about the current user (#1419)
* ICU-653 Stopped filtering out join/leave messages about the current user * Switched redux back to master
This commit is contained in:
parent
c4c4ddd7cf
commit
d187399fce
3 changed files with 40 additions and 14 deletions
|
|
@ -4,9 +4,9 @@
|
|||
import {Posts, Preferences} from 'mattermost-redux/constants';
|
||||
import {makeGetPostsForIds} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {getBool} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import {createIdsSelector} from 'mattermost-redux/utils/helpers';
|
||||
import {shouldFilterPost} from 'mattermost-redux/utils/post_utils';
|
||||
import {shouldFilterJoinLeavePost} from 'mattermost-redux/utils/post_utils';
|
||||
|
||||
export const DATE_LINE = 'date-';
|
||||
export const START_OF_NEW_MESSAGES = 'start-of-new-messages';
|
||||
|
|
@ -26,10 +26,10 @@ export function makePreparePostIdsForPostList() {
|
|||
(state, props) => getMyPosts(state, props.postIds),
|
||||
(state, props) => props.lastViewedAt,
|
||||
(state, props) => props.indicateNewMessages,
|
||||
getCurrentUserId,
|
||||
getCurrentUser,
|
||||
shouldShowJoinLeaveMessages,
|
||||
(posts, lastViewedAt, indicateNewMessages, currentUserId, showJoinLeave) => {
|
||||
if (posts.length === 0) {
|
||||
(posts, lastViewedAt, indicateNewMessages, currentUser, showJoinLeave) => {
|
||||
if (posts.length === 0 || !currentUser) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
@ -38,18 +38,16 @@ export function makePreparePostIdsForPostList() {
|
|||
let lastDate = null;
|
||||
let addedNewMessagesIndicator = false;
|
||||
|
||||
const filterOptions = {showJoinLeave};
|
||||
|
||||
// Iterating through the posts from oldest to newest
|
||||
for (let i = posts.length - 1; i >= 0; i--) {
|
||||
const post = posts[i];
|
||||
|
||||
if (post.state === Posts.POST_DELETED && post.user_id === currentUserId) {
|
||||
if (post.state === Posts.POST_DELETED && post.user_id === currentUser.id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filter out join/leave messages if necessary
|
||||
if (shouldFilterPost(post, filterOptions)) {
|
||||
if (shouldFilterJoinLeavePost(post, showJoinLeave, currentUser.username)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +61,7 @@ export function makePreparePostIdsForPostList() {
|
|||
}
|
||||
|
||||
// Only add the new messages line if a lastViewedAt time is set
|
||||
const postIsUnread = post.create_at > lastViewedAt && post.user_id !== currentUserId;
|
||||
const postIsUnread = post.create_at > lastViewedAt && post.user_id !== currentUser.id;
|
||||
if (lastViewedAt !== null && !addedNewMessagesIndicator && postIsUnread && indicateNewMessages) {
|
||||
out.push(START_OF_NEW_MESSAGES);
|
||||
addedNewMessagesIndicator = true;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,10 @@ describe('Selectors.PostList', () => {
|
|||
myPreferences: {}
|
||||
},
|
||||
users: {
|
||||
currentUserId: '1234'
|
||||
currentUserId: '1234',
|
||||
profiles: {
|
||||
1234: {id: '1234', username: 'user'}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -84,6 +87,25 @@ describe('Selectors.PostList', () => {
|
|||
|
||||
now = preparePostIdsForPostList(state, {postIds, lastViewedAt, indicateNewMessages});
|
||||
assert.deepEqual(removeDateLines(now), ['1001']);
|
||||
|
||||
// always show join/leave posts for the current user
|
||||
state = {
|
||||
...state,
|
||||
entities: {
|
||||
...state.entities,
|
||||
posts: {
|
||||
...state.entities.posts,
|
||||
posts: {
|
||||
...state.entities.posts.posts,
|
||||
1002: {id: '1002', create_at: 1, type: Posts.POST_TYPES.JOIN_CHANNEL, props: {username: 'user'}}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
now = preparePostIdsForPostList(state, {postIds, lastViewedAt, indicateNewMessages});
|
||||
|
||||
assert.deepEqual(removeDateLines(now), ['1002', '1001']);
|
||||
});
|
||||
|
||||
it('new messages indicator', () => {
|
||||
|
|
@ -102,7 +124,10 @@ describe('Selectors.PostList', () => {
|
|||
myPreferences: {}
|
||||
},
|
||||
users: {
|
||||
currentUserId: '1234'
|
||||
currentUserId: '1234',
|
||||
profiles: {
|
||||
1234: {id: '1234', username: 'user'}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -149,7 +174,10 @@ describe('Selectors.PostList', () => {
|
|||
}
|
||||
},
|
||||
users: {
|
||||
currentUserId: '1234'
|
||||
currentUserId: '1234',
|
||||
profiles: {
|
||||
1234: {id: '1234', username: 'user'}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3974,7 +3974,7 @@ makeerror@1.0.x:
|
|||
|
||||
mattermost-redux@mattermost/mattermost-redux:
|
||||
version "1.1.0"
|
||||
resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/7f2f352372a5ba587ed932c41eb550ba2cb1e94c"
|
||||
resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/1e81d05145f439e3aedae779e6c749c2b93f0e08"
|
||||
dependencies:
|
||||
deep-equal "1.0.1"
|
||||
form-data "2.3.1"
|
||||
|
|
|
|||
Loading…
Reference in a new issue