Minor tweak
This commit is contained in:
parent
1ff77118f5
commit
69214bee93
|
@ -68,8 +68,8 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
class CreateChannelView extends React.Component {
|
class CreateChannelView extends React.Component {
|
||||||
static navigationOptions = ({ route }) => ({
|
static navigationOptions = () => ({
|
||||||
title: route?.params?.isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')
|
title: this.isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')
|
||||||
})
|
})
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -90,12 +90,17 @@ class CreateChannelView extends React.Component {
|
||||||
theme: PropTypes.string
|
theme: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
constructor(props) {
|
||||||
channelName: '',
|
super(props);
|
||||||
type: true,
|
const { route } = this.props;
|
||||||
readOnly: false,
|
this.isTeam = route?.params?.isTeam || false;
|
||||||
encrypted: false,
|
this.state = {
|
||||||
broadcast: false
|
channelName: '',
|
||||||
|
type: true,
|
||||||
|
readOnly: false,
|
||||||
|
encrypted: false,
|
||||||
|
broadcast: false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
@ -156,9 +161,8 @@ class CreateChannelView extends React.Component {
|
||||||
channelName, type, readOnly, broadcast, encrypted
|
channelName, type, readOnly, broadcast, encrypted
|
||||||
} = this.state;
|
} = this.state;
|
||||||
const {
|
const {
|
||||||
users: usersProps, isFetching, create, route
|
users: usersProps, isFetching, create
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isTeam } = route?.params;
|
|
||||||
|
|
||||||
if (!channelName.trim() || isFetching) {
|
if (!channelName.trim() || isFetching) {
|
||||||
return;
|
return;
|
||||||
|
@ -169,7 +173,7 @@ class CreateChannelView extends React.Component {
|
||||||
|
|
||||||
// create channel or team
|
// create channel or team
|
||||||
create({
|
create({
|
||||||
name: channelName, users, type, readOnly, broadcast, encrypted, isTeam
|
name: channelName, users, type, readOnly, broadcast, encrypted, isTeam: this.isTeam
|
||||||
});
|
});
|
||||||
|
|
||||||
Review.pushPositiveEvent();
|
Review.pushPositiveEvent();
|
||||||
|
@ -201,13 +205,11 @@ class CreateChannelView extends React.Component {
|
||||||
|
|
||||||
renderType() {
|
renderType() {
|
||||||
const { type } = this.state;
|
const { type } = this.state;
|
||||||
const { route } = this.props;
|
|
||||||
const { isTeam } = route?.params;
|
|
||||||
|
|
||||||
return this.renderSwitch({
|
return this.renderSwitch({
|
||||||
id: 'type',
|
id: 'type',
|
||||||
value: type,
|
value: type,
|
||||||
label: isTeam ? 'Private_Team' : 'Private_Channel',
|
label: this.isTeam ? 'Private_Team' : 'Private_Channel',
|
||||||
onValueChange: (value) => {
|
onValueChange: (value) => {
|
||||||
logEvent(events.CR_TOGGLE_TYPE);
|
logEvent(events.CR_TOGGLE_TYPE);
|
||||||
// If we set the channel as public, encrypted status should be false
|
// If we set the channel as public, encrypted status should be false
|
||||||
|
@ -218,13 +220,11 @@ class CreateChannelView extends React.Component {
|
||||||
|
|
||||||
renderReadOnly() {
|
renderReadOnly() {
|
||||||
const { readOnly, broadcast } = this.state;
|
const { readOnly, broadcast } = this.state;
|
||||||
const { route } = this.props;
|
|
||||||
const { isTeam } = route?.params;
|
|
||||||
|
|
||||||
return this.renderSwitch({
|
return this.renderSwitch({
|
||||||
id: 'readonly',
|
id: 'readonly',
|
||||||
value: readOnly,
|
value: readOnly,
|
||||||
label: isTeam ? 'Read_Only_Team' : 'Read_Only_Channel',
|
label: this.isTeam ? 'Read_Only_Team' : 'Read_Only_Channel',
|
||||||
onValueChange: (value) => {
|
onValueChange: (value) => {
|
||||||
logEvent(events.CR_TOGGLE_READ_ONLY);
|
logEvent(events.CR_TOGGLE_READ_ONLY);
|
||||||
this.setState({ readOnly: value });
|
this.setState({ readOnly: value });
|
||||||
|
@ -255,13 +255,11 @@ class CreateChannelView extends React.Component {
|
||||||
|
|
||||||
renderBroadcast() {
|
renderBroadcast() {
|
||||||
const { broadcast, readOnly } = this.state;
|
const { broadcast, readOnly } = this.state;
|
||||||
const { route } = this.props;
|
|
||||||
const { isTeam } = route?.params;
|
|
||||||
|
|
||||||
return this.renderSwitch({
|
return this.renderSwitch({
|
||||||
id: 'broadcast',
|
id: 'broadcast',
|
||||||
value: broadcast,
|
value: broadcast,
|
||||||
label: isTeam ? 'Broadcast_Team' : 'Broadcast_Channel',
|
label: this.isTeam ? 'Broadcast_Team' : 'Broadcast_Channel',
|
||||||
onValueChange: (value) => {
|
onValueChange: (value) => {
|
||||||
logEvent(events.CR_TOGGLE_BROADCAST);
|
logEvent(events.CR_TOGGLE_BROADCAST);
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -316,9 +314,8 @@ class CreateChannelView extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const { channelName } = this.state;
|
const { channelName } = this.state;
|
||||||
const {
|
const {
|
||||||
users, isFetching, route, theme
|
users, isFetching, theme
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isTeam } = route?.params;
|
|
||||||
const userCount = users.length;
|
const userCount = users.length;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -328,18 +325,18 @@ class CreateChannelView extends React.Component {
|
||||||
keyboardVerticalOffset={128}
|
keyboardVerticalOffset={128}
|
||||||
>
|
>
|
||||||
<StatusBar />
|
<StatusBar />
|
||||||
<SafeAreaView testID={isTeam ? 'create-team-view' : 'create-channel-view'}>
|
<SafeAreaView testID={this.isTeam ? 'create-team-view' : 'create-channel-view'}>
|
||||||
<ScrollView {...scrollPersistTaps}>
|
<ScrollView {...scrollPersistTaps}>
|
||||||
<View style={[sharedStyles.separatorVertical, { borderColor: themes[theme].separatorColor }]}>
|
<View style={[sharedStyles.separatorVertical, { borderColor: themes[theme].separatorColor }]}>
|
||||||
<TextInput
|
<TextInput
|
||||||
autoFocus
|
autoFocus
|
||||||
style={[styles.input, { backgroundColor: themes[theme].backgroundColor }]}
|
style={[styles.input, { backgroundColor: themes[theme].backgroundColor }]}
|
||||||
label={isTeam ? I18n.t('Team_Name') : I18n.t('Channel_Name')}
|
label={this.isTeam ? I18n.t('Team_Name') : I18n.t('Channel_Name')}
|
||||||
value={channelName}
|
value={channelName}
|
||||||
onChangeText={this.onChangeText}
|
onChangeText={this.onChangeText}
|
||||||
placeholder={isTeam ? I18n.t('Team_Name') : I18n.t('Channel_Name')}
|
placeholder={this.isTeam ? I18n.t('Team_Name') : I18n.t('Channel_Name')}
|
||||||
returnKeyType='done'
|
returnKeyType='done'
|
||||||
testID={isTeam ? 'create-team-name' : 'create-channel-name'}
|
testID={this.isTeam ? 'create-team-name' : 'create-channel-name'}
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
autoCapitalize='none'
|
autoCapitalize='none'
|
||||||
theme={theme}
|
theme={theme}
|
||||||
|
|
|
@ -113,7 +113,7 @@ class NewMessageView extends React.Component {
|
||||||
createChannel = () => {
|
createChannel = () => {
|
||||||
logEvent(events.NEW_MSG_CREATE_CHANNEL);
|
logEvent(events.NEW_MSG_CREATE_CHANNEL);
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
navigation.navigate('SelectedUsersViewCreateChannel', { nextAction: () => navigation.navigate('CreateChannelView', { isTeam: false }) });
|
navigation.navigate('SelectedUsersViewCreateChannel', { nextAction: () => navigation.navigate('CreateChannelView') });
|
||||||
}
|
}
|
||||||
|
|
||||||
createTeam = () => {
|
createTeam = () => {
|
||||||
|
|
Loading…
Reference in New Issue