From d7a85fe2de36cbbd029d87b0befea2f2803260d5 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Wed, 14 Aug 2019 21:54:46 +0200 Subject: [PATCH] Automated cherry pick of #3123 (#3124) * Set header buttons after mount * Do the same for private channel and dm --- app/screens/create_channel/create_channel.js | 10 ---------- app/screens/more_channels/more_channels.js | 17 ++++------------- app/screens/more_channels/more_channels.test.js | 4 ++-- app/screens/more_dms/more_dms.js | 3 +-- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/app/screens/create_channel/create_channel.js b/app/screens/create_channel/create_channel.js index 1e5994e7c..7ff26e6ee 100644 --- a/app/screens/create_channel/create_channel.js +++ b/app/screens/create_channel/create_channel.js @@ -67,16 +67,6 @@ export default class CreateChannel extends PureComponent { if (props.closeButton) { this.left = {...this.leftButton, icon: props.closeButton}; } - - const buttons = { - rightButtons: [this.rightButton], - }; - - if (this.left) { - buttons.leftButtons = [this.left]; - } - - props.actions.setButtons(props.componentId, buttons); } componentDidMount() { diff --git a/app/screens/more_channels/more_channels.js b/app/screens/more_channels/more_channels.js index 416a0bf53..a95b15392 100644 --- a/app/screens/more_channels/more_channels.js +++ b/app/screens/more_channels/more_channels.js @@ -75,21 +75,12 @@ export default class MoreChannels extends PureComponent { id: 'close-more-channels', icon: props.closeButton, }; - - const buttons = { - leftButtons: [this.leftButton], - }; - - if (props.canCreateChannels) { - buttons.rightButtons = [this.rightButton]; - } - - props.actions.setButtons(props.componentId, buttons); } componentDidMount() { this.navigationEventListener = Navigation.events().bindComponent(this); this.mounted = true; + this.setHeaderButtons(this.props.canCreateChannels); this.doGetChannels(); } @@ -165,7 +156,7 @@ export default class MoreChannels extends PureComponent { getChannels = debounce(this.doGetChannels, 100); - headerButtons = (createEnabled) => { + setHeaderButtons = (createEnabled) => { const {actions, canCreateChannels, componentId} = this.props; const buttons = { leftButtons: [this.leftButton], @@ -194,7 +185,7 @@ export default class MoreChannels extends PureComponent { const {actions, currentTeamId, currentUserId} = this.props; const {channels} = this.state; - this.headerButtons(false); + this.setHeaderButtons(false); this.setState({adding: true}); const channel = channels.find((c) => c.id === id); @@ -212,7 +203,7 @@ export default class MoreChannels extends PureComponent { displayName: channel ? channel.display_name : '', } ); - this.headerButtons(true); + this.setHeaderButtons(true); this.setState({adding: false}); } else { if (channel) { diff --git a/app/screens/more_channels/more_channels.test.js b/app/screens/more_channels/more_channels.test.js index 7fe062b9f..d114a1067 100644 --- a/app/screens/more_channels/more_channels.test.js +++ b/app/screens/more_channels/more_channels.test.js @@ -52,14 +52,14 @@ describe('MoreChannels', () => { expect(baseProps.actions.dismissModal).toHaveBeenCalledTimes(1); }); - test('should call props.actions.setButtons on headerButtons', () => { + test('should call props.actions.setButtons on setHeaderButtons', () => { const wrapper = shallow( , {context: {intl: {formatMessage: jest.fn()}}}, ); expect(baseProps.actions.setButtons).toHaveBeenCalledTimes(1); - wrapper.instance().headerButtons(true); + wrapper.instance().setHeaderButtons(true); expect(baseProps.actions.setButtons).toHaveBeenCalledTimes(2); }); diff --git a/app/screens/more_dms/more_dms.js b/app/screens/more_dms/more_dms.js index 3f1640020..790887545 100644 --- a/app/screens/more_dms/more_dms.js +++ b/app/screens/more_dms/more_dms.js @@ -73,13 +73,12 @@ export default class MoreDirectMessages extends PureComponent { selectedIds: {}, selectedCount: 0, }; - - this.updateNavigationButtons(false, context); } componentDidMount() { this.navigationEventListener = Navigation.events().bindComponent(this); this.mounted = true; + this.updateNavigationButtons(false); this.getProfiles(); }