* Set header buttons after mount * Do the same for private channel and dm
This commit is contained in:
parent
c1957ac6a0
commit
d7a85fe2de
4 changed files with 7 additions and 27 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
<MoreChannels {...baseProps}/>,
|
||||
{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);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue