Fix Create on Create channel to not push another Create Channel screen (#820)
This commit is contained in:
parent
10fd389e15
commit
12f6b11e09
4 changed files with 32 additions and 7 deletions
|
|
@ -273,7 +273,6 @@ class List extends Component {
|
|||
screenBackgroundColor: theme.centerChannelBg
|
||||
},
|
||||
passProps: {
|
||||
channelType: General.PRIVATE_CHANNEL,
|
||||
closeButton: this.closeButton
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue