Fixed custom status issues (#5476) (#5477)

Fixed MM-36571 and MM-36601 issues by dispatching RECEIVED_ME action on websocket reconnecting
Added memoization in makeGetCustomStatus in custom status emoji component
Fixed e2e test case failing due to post header custom status emoji

(cherry picked from commit c06b5ecb4f)

Co-authored-by: Manoj Malik <manoj@brightscout.com>
This commit is contained in:
Mattermost Build 2021-06-22 19:34:05 +02:00 committed by GitHub
parent d78ad793a8
commit 2119cb4f85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

View file

@ -151,6 +151,9 @@ export function doReconnect(now: number) {
}
actions.push({
type: UserTypes.RECEIVED_ME,
data: me.user,
}, {
type: PreferenceTypes.RECEIVED_ALL_PREFERENCES,
data: me.preferences,
}, {

View file

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import React, {useMemo} from 'react';
import {Text, TextStyle} from 'react-native';
import {useSelector} from 'react-redux';
@ -17,7 +17,7 @@ interface ComponentProps {
}
const CustomStatusEmoji = ({emojiSize, userID, style, testID}: ComponentProps) => {
const getCustomStatus = makeGetCustomStatus();
const getCustomStatus = useMemo(makeGetCustomStatus, []);
const customStatus = useSelector((state: GlobalState) => {
return getCustomStatus(state, userID);
});

View file

@ -92,6 +92,7 @@ const Header = ({
<CustomStatusEmoji
userID={post.user_id}
style={style.customStatusEmoji}
testID='post_header'
/>
)}
{!isSystemPost &&

View file

@ -213,14 +213,14 @@ describe('Custom status', () => {
// # Post a message and check if custom status emoji is present in the post header
await ChannelScreen.postMessage(message);
await expect(element(by.id(`custom_status_emoji.${customStatus.emojiName}`).withAncestor(by.id('post_header')))).toBeVisible();
await expect(element(by.id(`post_header.custom_status_emoji.${customStatus.emojiName}`))).toBeVisible();
// # Open the reply thread for the last post
const {post} = await Post.apiGetLastPostInChannel(testChannel.id);
await ChannelScreen.openReplyThreadFor(post.id, message);
// * Check if the custom status emoji is present in the post header and close thread
await expect(element(by.id(`custom_status_emoji.${customStatus.emojiName}`).withAncestor(by.id('post_header')))).toBeVisible();
await expect(element(by.id(`post_header.custom_status_emoji.${customStatus.emojiName}`))).toBeVisible();
await ThreadScreen.back();
// # Open user profile screen