diff --git a/app/views/CreateChannelView.js b/app/views/CreateChannelView.js
index 59b2ac06e..54d70d80b 100644
--- a/app/views/CreateChannelView.js
+++ b/app/views/CreateChannelView.js
@@ -68,8 +68,8 @@ const styles = StyleSheet.create({
});
class CreateChannelView extends React.Component {
- static navigationOptions = ({ route }) => ({
- title: route?.params?.isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')
+ static navigationOptions = () => ({
+ title: this.isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')
})
static propTypes = {
@@ -90,12 +90,17 @@ class CreateChannelView extends React.Component {
theme: PropTypes.string
};
- state = {
- channelName: '',
- type: true,
- readOnly: false,
- encrypted: false,
- broadcast: false
+ constructor(props) {
+ super(props);
+ const { route } = this.props;
+ this.isTeam = route?.params?.isTeam || false;
+ this.state = {
+ channelName: '',
+ type: true,
+ readOnly: false,
+ encrypted: false,
+ broadcast: false
+ };
}
shouldComponentUpdate(nextProps, nextState) {
@@ -156,9 +161,8 @@ class CreateChannelView extends React.Component {
channelName, type, readOnly, broadcast, encrypted
} = this.state;
const {
- users: usersProps, isFetching, create, route
+ users: usersProps, isFetching, create
} = this.props;
- const { isTeam } = route?.params;
if (!channelName.trim() || isFetching) {
return;
@@ -169,7 +173,7 @@ class CreateChannelView extends React.Component {
// create channel or team
create({
- name: channelName, users, type, readOnly, broadcast, encrypted, isTeam
+ name: channelName, users, type, readOnly, broadcast, encrypted, isTeam: this.isTeam
});
Review.pushPositiveEvent();
@@ -201,13 +205,11 @@ class CreateChannelView extends React.Component {
renderType() {
const { type } = this.state;
- const { route } = this.props;
- const { isTeam } = route?.params;
return this.renderSwitch({
id: 'type',
value: type,
- label: isTeam ? 'Private_Team' : 'Private_Channel',
+ label: this.isTeam ? 'Private_Team' : 'Private_Channel',
onValueChange: (value) => {
logEvent(events.CR_TOGGLE_TYPE);
// If we set the channel as public, encrypted status should be false
@@ -218,13 +220,11 @@ class CreateChannelView extends React.Component {
renderReadOnly() {
const { readOnly, broadcast } = this.state;
- const { route } = this.props;
- const { isTeam } = route?.params;
return this.renderSwitch({
id: 'readonly',
value: readOnly,
- label: isTeam ? 'Read_Only_Team' : 'Read_Only_Channel',
+ label: this.isTeam ? 'Read_Only_Team' : 'Read_Only_Channel',
onValueChange: (value) => {
logEvent(events.CR_TOGGLE_READ_ONLY);
this.setState({ readOnly: value });
@@ -255,13 +255,11 @@ class CreateChannelView extends React.Component {
renderBroadcast() {
const { broadcast, readOnly } = this.state;
- const { route } = this.props;
- const { isTeam } = route?.params;
return this.renderSwitch({
id: 'broadcast',
value: broadcast,
- label: isTeam ? 'Broadcast_Team' : 'Broadcast_Channel',
+ label: this.isTeam ? 'Broadcast_Team' : 'Broadcast_Channel',
onValueChange: (value) => {
logEvent(events.CR_TOGGLE_BROADCAST);
this.setState({
@@ -316,9 +314,8 @@ class CreateChannelView extends React.Component {
render() {
const { channelName } = this.state;
const {
- users, isFetching, route, theme
+ users, isFetching, theme
} = this.props;
- const { isTeam } = route?.params;
const userCount = users.length;
return (
@@ -328,18 +325,18 @@ class CreateChannelView extends React.Component {
keyboardVerticalOffset={128}
>
-
+
{
logEvent(events.NEW_MSG_CREATE_CHANNEL);
const { navigation } = this.props;
- navigation.navigate('SelectedUsersViewCreateChannel', { nextAction: () => navigation.navigate('CreateChannelView', { isTeam: false }) });
+ navigation.navigate('SelectedUsersViewCreateChannel', { nextAction: () => navigation.navigate('CreateChannelView') });
}
createTeam = () => {