MM-10340 Fix "More New Messages Above" that appears on top of the channel after joining (#1710)
* Replace "More New Messages Above" with "New Messages" that appears on top of the channel after joining Signed-off-by: Saturnino Abril <saturnino.abril@gmail.com> * add conditions in adding entry of start of new messages in preparing post IDs for post list * remove post unread for user joinining the channel * refactor and remove unnecessary conditional check * fix and add test cases
This commit is contained in:
parent
b12d4cd91b
commit
2f3488f622
2 changed files with 21 additions and 4 deletions
|
|
@ -65,9 +65,13 @@ export function makePreparePostIdsForPostList() {
|
|||
lastDate = postDate;
|
||||
}
|
||||
|
||||
// Only add the new messages line if a lastViewedAt time is set
|
||||
const postIsUnread = post.create_at > lastViewedAt && post.user_id !== currentUser.id;
|
||||
if (lastViewedAt !== null && !addedNewMessagesIndicator && postIsUnread && indicateNewMessages) {
|
||||
if (
|
||||
lastViewedAt &&
|
||||
post.create_at > lastViewedAt &&
|
||||
post.user_id !== currentUser.id &&
|
||||
!addedNewMessagesIndicator &&
|
||||
indicateNewMessages
|
||||
) {
|
||||
out.push(START_OF_NEW_MESSAGES);
|
||||
addedNewMessagesIndicator = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,14 +136,27 @@ describe('Selectors.PostList', () => {
|
|||
|
||||
const postIds = ['1010', '1005', '1000']; // Remember that we list the posts backwards
|
||||
|
||||
// Show new messages indicator before all posts
|
||||
// Do not show new messages indicator before all posts
|
||||
let now = preparePostIdsForPostList(state, {postIds, lastViewedAt: 0, indicateNewMessages: true});
|
||||
assert.deepEqual(removeDateLines(now), ['1010', '1005', '1000']);
|
||||
|
||||
now = preparePostIdsForPostList(state, {postIds, indicateNewMessages: true});
|
||||
assert.deepEqual(removeDateLines(now), ['1010', '1005', '1000']);
|
||||
|
||||
now = preparePostIdsForPostList(state, {postIds, lastViewedAt: 999, indicateNewMessages: false});
|
||||
assert.deepEqual(removeDateLines(now), ['1010', '1005', '1000']);
|
||||
|
||||
// Show new messages indicator before all posts
|
||||
now = preparePostIdsForPostList(state, {postIds, lastViewedAt: 999, indicateNewMessages: true});
|
||||
assert.deepEqual(removeDateLines(now), ['1010', '1005', '1000', START_OF_NEW_MESSAGES]);
|
||||
|
||||
// Show indicator between posts
|
||||
now = preparePostIdsForPostList(state, {postIds, lastViewedAt: 1003, indicateNewMessages: true});
|
||||
assert.deepEqual(removeDateLines(now), ['1010', '1005', START_OF_NEW_MESSAGES, '1000']);
|
||||
|
||||
now = preparePostIdsForPostList(state, {postIds, lastViewedAt: 1006, indicateNewMessages: true});
|
||||
assert.deepEqual(removeDateLines(now), ['1010', START_OF_NEW_MESSAGES, '1005', '1000']);
|
||||
|
||||
// Don't show indicator when all posts are read
|
||||
now = preparePostIdsForPostList(state, {postIds, lastViewedAt: 1020});
|
||||
assert.deepEqual(removeDateLines(now), ['1010', '1005', '1000']);
|
||||
|
|
|
|||
Loading…
Reference in a new issue