From 1d94fb6e16eee6bbee66edcc0cd8d39e57e37d6e Mon Sep 17 00:00:00 2001 From: Miguel Alatzar Date: Thu, 24 Sep 2020 10:56:35 -0700 Subject: [PATCH] Exclude NotificationPreference for DMs (#4831) --- .../__snapshots__/channel_info.test.js.snap | 812 ++++++++++++++++++ app/screens/channel_info/channel_info.js | 9 +- app/screens/channel_info/channel_info.test.js | 18 + app/screens/channel_info/index.js | 4 +- 4 files changed, 839 insertions(+), 4 deletions(-) diff --git a/app/screens/channel_info/__snapshots__/channel_info.test.js.snap b/app/screens/channel_info/__snapshots__/channel_info.test.js.snap index dfb411f45..0bab421c9 100644 --- a/app/screens/channel_info/__snapshots__/channel_info.test.js.snap +++ b/app/screens/channel_info/__snapshots__/channel_info.test.js.snap @@ -571,3 +571,815 @@ exports[`channelInfo should match snapshot 1`] = ` `; + +exports[`channelInfo should not include NotificationPreference for direct message 1`] = ` + + + + + + + + + + + + + + + +`; + +exports[`channelInfo should not include NotificationPreference for direct message 2`] = ` + + + + + + + + + + + + + + +`; diff --git a/app/screens/channel_info/channel_info.js b/app/screens/channel_info/channel_info.js index 0a8759694..502aee3da 100644 --- a/app/screens/channel_info/channel_info.js +++ b/app/screens/channel_info/channel_info.js @@ -45,6 +45,7 @@ export default class ChannelInfo extends PureComponent { isBot: PropTypes.bool.isRequired, isLandscape: PropTypes.bool.isRequired, isTeammateGuest: PropTypes.bool.isRequired, + isDirectMessage: PropTypes.bool.isRequired, status: PropTypes.string, theme: PropTypes.object.isRequired, }; @@ -109,8 +110,8 @@ export default class ChannelInfo extends PureComponent { showModalOverCurrentContext(screen, passProps, options); }; - actionsRows = (style, channelIsArchived) => { - const {currentChannel, currentUserId, isLandscape, theme} = this.props; + actionsRows = (channelIsArchived) => { + const {currentChannel, currentUserId, isLandscape, isDirectMessage, theme} = this.props; if (channelIsArchived) { return ( @@ -142,10 +143,12 @@ export default class ChannelInfo extends PureComponent { theme={theme} /> + {!isDirectMessage && + } } - {this.actionsRows(style, channelIsArchived)} + {this.actionsRows(channelIsArchived)} { const original = jest.requireActual('../../utils/theme'); @@ -47,6 +48,7 @@ describe('channelInfo', () => { theme: Preferences.THEMES.default, isBot: false, isTeammateGuest: false, + isDirectMessage: false, isLandscape: false, actions: { getChannelStats: jest.fn(), @@ -81,4 +83,20 @@ describe('channelInfo', () => { instance.close(); expect(dismissModal).toHaveBeenCalled(); }); + + test('should not include NotificationPreference for direct message', () => { + const wrapper = shallow( + , + {context: {intl: intlMock}}, + ); + + expect(wrapper.instance().actionsRows()).toMatchSnapshot(); + expect(wrapper.find(NotificationPreference).exists()).toEqual(true); + + wrapper.setProps({isDirectMessage: true}); + expect(wrapper.instance().actionsRows()).toMatchSnapshot(); + expect(wrapper.find(NotificationPreference).exists()).toEqual(false); + }); }); diff --git a/app/screens/channel_info/index.js b/app/screens/channel_info/index.js index 3defab5bf..f3a69b91d 100644 --- a/app/screens/channel_info/index.js +++ b/app/screens/channel_info/index.js @@ -32,7 +32,8 @@ function mapStateToProps(state) { let status; let isBot = false; let isTeammateGuest = false; - if (currentChannel.type === General.DM_CHANNEL) { + const isDirectMessage = currentChannel.type === General.DM_CHANNEL; + if (isDirectMessage) { const teammateId = getUserIdFromChannelName(currentUserId, currentChannel.name); const teammate = getUser(state, teammateId); status = getStatusForUserId(state, teammateId); @@ -54,6 +55,7 @@ function mapStateToProps(state) { isBot, isLandscape: isLandscape(state), isTeammateGuest, + isDirectMessage, status, theme: getTheme(state), };