diff --git a/actions/emoji_actions.js b/actions/emoji_actions.js index f1203d51feea..88188a9adda0 100644 --- a/actions/emoji_actions.js +++ b/actions/emoji_actions.js @@ -77,6 +77,7 @@ export function addRecentEmoji(alias) { } export function loadCustomEmojisForCustomStatusesByUserIds(userIds) { + const getCustomStatus = makeGetCustomStatus(); return (dispatch, getState) => { const state = getState(); const customEmojiEnabled = isCustomEmojiEnabled(state); @@ -85,7 +86,6 @@ export function loadCustomEmojisForCustomStatusesByUserIds(userIds) { return {data: false}; } - const getCustomStatus = makeGetCustomStatus(); const emojisToLoad = new Set(); userIds.forEach((userId) => { diff --git a/components/channel_header/__snapshots__/channel_header.test.jsx.snap b/components/channel_header/__snapshots__/channel_header.test.jsx.snap index c92ca431e47b..f7feae4076f5 100644 --- a/components/channel_header/__snapshots__/channel_header.test.jsx.snap +++ b/components/channel_header/__snapshots__/channel_header.test.jsx.snap @@ -1237,6 +1237,217 @@ exports[`components/ChannelHeader should render not active channel files 1`] = ` `; +exports[`components/ChannelHeader should render properly when custom status is expired 1`] = ` + +`; + exports[`components/ChannelHeader should render properly when custom status is set 1`] = `
Utils.handleFormattedTextClick(e, this.props.currentRelativeTeamUrl); renderCustomStatus = () => { - const {customStatus} = this.props; - const isStatusSet = customStatus && (customStatus.text || customStatus.emoji); - if (!(this.props.isCustomStatusEnabled && isStatusSet)) { + const {customStatus, isCustomStatusEnabled, isCustomStatusExpired} = this.props; + const isStatusSet = !isCustomStatusExpired && (customStatus?.text || customStatus?.emoji); + if (!(isCustomStatusEnabled && isStatusSet)) { return null; } @@ -230,6 +231,8 @@ class ChannelHeader extends React.PureComponent { <> { teammateNameDisplaySetting: '', currentRelativeTeamUrl: '', isCustomStatusEnabled: false, + isCustomStatusExpired: false, }; const populatedProps = { @@ -309,4 +310,30 @@ describe('components/ChannelHeader', () => { ); expect(wrapper).toMatchSnapshot(); }); + + test('should render properly when custom status is expired', () => { + const props = { + ...populatedProps, + channel: { + header: 'not the bot description', + type: Constants.DM_CHANNEL, + status: 'offline', + }, + dmUser: { + id: 'user_id', + is_bot: false, + }, + isCustomStatusEnabled: true, + isCustomStatusExpired: true, + customStatus: { + emoji: 'calender', + text: 'In a meeting', + }, + }; + + const wrapper = shallowWithIntl( + , + ); + expect(wrapper).toMatchSnapshot(); + }); }); diff --git a/components/channel_header/index.js b/components/channel_header/index.js index 6a6107a4c740..b145dbc5436b 100644 --- a/components/channel_header/index.js +++ b/components/channel_header/index.js @@ -39,7 +39,7 @@ import { showMentions, closeRightHandSide, } from 'actions/views/rhs'; -import {makeGetCustomStatus, isCustomStatusEnabled} from 'selectors/views/custom_status'; +import {makeGetCustomStatus, isCustomStatusEnabled, isCustomStatusExpired} from 'selectors/views/custom_status'; import {getIsRhsOpen, getRhsState} from 'selectors/rhs'; import {isModalOpen} from 'selectors/views/modals'; import {getAnnouncementBarCount} from 'selectors/views/announcement_bar'; @@ -92,6 +92,7 @@ function makeMapStateToProps() { announcementBarCount: getAnnouncementBarCount(state), customStatus, isCustomStatusEnabled: isCustomStatusEnabled(state), + isCustomStatusExpired: isCustomStatusExpired(state, customStatus), }; }; } diff --git a/components/custom_status/__snapshots__/custom_status_suggestion.test.tsx.snap b/components/custom_status/__snapshots__/custom_status_suggestion.test.tsx.snap index 43b70c3c600b..de0db09f409a 100644 --- a/components/custom_status/__snapshots__/custom_status_suggestion.test.tsx.snap +++ b/components/custom_status/__snapshots__/custom_status_suggestion.test.tsx.snap @@ -22,3 +22,34 @@ exports[`components/custom_status/custom_status_emoji should match snapshot 1`] />
`; + +exports[`components/custom_status/custom_status_emoji should match snapshot with duration 1`] = ` +
+
+ +
+ + + + +
+`; diff --git a/components/custom_status/__snapshots__/date_time_input.test.tsx.snap b/components/custom_status/__snapshots__/date_time_input.test.tsx.snap new file mode 100644 index 000000000000..e5edc492dba9 --- /dev/null +++ b/components/custom_status/__snapshots__/date_time_input.test.tsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/custom_status/date_time_input should match snapshot 1`] = ` + +`; diff --git a/components/custom_status/__snapshots__/expiry_menu.test.tsx.snap b/components/custom_status/__snapshots__/expiry_menu.test.tsx.snap new file mode 100644 index 000000000000..7c8164bca29d --- /dev/null +++ b/components/custom_status/__snapshots__/expiry_menu.test.tsx.snap @@ -0,0 +1,159 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/custom_status/expiry_menu should match snapshot 1`] = ` + +
+
+ +
+ + + + Clear after + + + : + + Don't clear + + +