diff --git a/app/components/channel_drawer/channels_list/list/list.js b/app/components/channel_drawer/channels_list/list/list.js index d93140896..83bb1216b 100644 --- a/app/components/channel_drawer/channels_list/list/list.js +++ b/app/components/channel_drawer/channels_list/list/list.js @@ -273,7 +273,6 @@ class List extends Component { screenBackgroundColor: theme.centerChannelBg }, passProps: { - channelType: General.PRIVATE_CHANNEL, closeButton: this.closeButton } }); diff --git a/app/screens/create_channel/create_channel.js b/app/screens/create_channel/create_channel.js index c7e7c8d22..d196ff113 100644 --- a/app/screens/create_channel/create_channel.js +++ b/app/screens/create_channel/create_channel.js @@ -128,6 +128,7 @@ class CreateChannel extends PureComponent { }; close = (goBack = false) => { + EventEmitter.emit('closing-create-channel', false); if (goBack) { this.props.navigator.pop({animated: true}); } else { diff --git a/app/screens/more_channels/index.js b/app/screens/more_channels/index.js index 74bfc07f7..92452bd81 100644 --- a/app/screens/more_channels/index.js +++ b/app/screens/more_channels/index.js @@ -3,6 +3,7 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; +import {createSelector} from 'reselect'; import {General} from 'mattermost-redux/constants'; import {getChannels, joinChannel, searchChannels} from 'mattermost-redux/actions/channels'; @@ -16,16 +17,23 @@ import {getTheme} from 'app/selectors/preferences'; import MoreChannels from './more_channels'; +const joinableChannels = createSelector( + getChannelsInCurrentTeam, + getMyChannelMemberships, + (channels, myMembers) => { + return channels.filter((c) => { + return (!myMembers[c.id] && c.type === General.OPEN_CHANNEL); + }); + } +); + function mapStateToProps(state, ownProps) { const {currentUserId} = state.entities.users; const {currentTeamId} = state.entities.teams; const {getChannels: requestStatus} = state.requests.channels; const {config, license} = state.entities.general; const roles = getCurrentUserRoles(state); - const myMembers = getMyChannelMemberships(state); - const channels = getChannelsInCurrentTeam(state).filter((c) => { - return (!myMembers[c.id] && c.type === General.OPEN_CHANNEL); - }); + const channels = joinableChannels(state); return { ...ownProps, diff --git a/app/screens/more_channels/more_channels.js b/app/screens/more_channels/more_channels.js index 03b6e5900..7ffd560f9 100644 --- a/app/screens/more_channels/more_channels.js +++ b/app/screens/more_channels/more_channels.js @@ -58,6 +58,7 @@ class MoreChannels extends PureComponent { this.state = { channels: props.channels.splice(0, General.CHANNELS_CHUNK_SIZE), + createScreenVisible: false, page: 0, adding: false, next: true, @@ -80,6 +81,10 @@ class MoreChannels extends PureComponent { props.navigator.setButtons(buttons); } + componentWillMount() { + EventEmitter.on('closing-create-channel', this.handleCreateScreenVisible); + } + componentDidMount() { // set the timeout to 400 cause is the time that the modal takes to open // Somehow interactionManager doesn't care @@ -101,7 +106,13 @@ class MoreChannels extends PureComponent { this.setState({channels, showNoResults: true}); } - this.headerButtons(nextProps.canCreateChannels, true); + if (!this.state.createScreenVisible) { + this.headerButtons(nextProps.canCreateChannels, true); + } + } + + componentWillUnmount() { + EventEmitter.off('closing-create-channel', this.handleCreateScreenVisible); } close = () => { @@ -112,6 +123,10 @@ class MoreChannels extends PureComponent { this.headerButtons(this.props.canCreateChannels, enabled); }; + handleCreateScreenVisible = (createScreenVisible) => { + this.setState({createScreenVisible}); + }; + headerButtons = (canCreateChannels, enabled) => { const buttons = { leftButtons: [this.leftButton] @@ -182,7 +197,9 @@ class MoreChannels extends PureComponent { this.close(); break; case 'create-pub-channel': - this.onCreateChannel(); + this.setState({ + createScreenVisible: true + }, this.onCreateChannel); break; } }