RN-483 Ensured switch statements used for i18n have a default case (#1196)
* RN-483 Ensured switch statements used for i18n have a default case * Made VectorIcon use a PureComponent
This commit is contained in:
parent
36c9913f79
commit
dc90ce46ae
4 changed files with 69 additions and 63 deletions
|
|
@ -172,6 +172,7 @@ export default class OfflineIndicator extends Component {
|
|||
);
|
||||
break;
|
||||
case CONNECTED:
|
||||
default:
|
||||
i18nId = 'mobile.offlineIndicator.connected';
|
||||
defaultMessage = 'Connected';
|
||||
action = (
|
||||
|
|
|
|||
|
|
@ -1,62 +1,64 @@
|
|||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, {PureComponent} from 'react';
|
||||
import {Text} from 'react-native';
|
||||
import IonIcon from 'react-native-vector-icons/Ionicons';
|
||||
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
|
||||
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
|
||||
import FoundationIcon from 'react-native-vector-icons/Foundation';
|
||||
import IonIcon from 'react-native-vector-icons/Ionicons';
|
||||
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
|
||||
|
||||
export default function vectorIcon(props) {
|
||||
const {name, type, style, size} = props;
|
||||
export default class VectorIcon extends PureComponent {
|
||||
static propTypes = {
|
||||
name: PropTypes.string,
|
||||
type: PropTypes.string,
|
||||
size: PropTypes.number,
|
||||
style: Text.propTypes.style
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
case 'fontawesome':
|
||||
return (
|
||||
<FontAwesomeIcon
|
||||
name={name}
|
||||
style={style}
|
||||
size={size}
|
||||
/>
|
||||
);
|
||||
case 'foundation':
|
||||
return (
|
||||
<FoundationIcon
|
||||
name={name}
|
||||
style={style}
|
||||
size={size}
|
||||
/>
|
||||
);
|
||||
case 'ion':
|
||||
return (
|
||||
<IonIcon
|
||||
name={name}
|
||||
style={style}
|
||||
size={size}
|
||||
/>
|
||||
);
|
||||
case 'material':
|
||||
return (
|
||||
<MaterialIcon
|
||||
name={name}
|
||||
style={style}
|
||||
size={size}
|
||||
/>
|
||||
);
|
||||
static defaultProps = {
|
||||
size: 14
|
||||
};
|
||||
|
||||
render() {
|
||||
const {name, type, style, size} = this.props;
|
||||
|
||||
switch (type) {
|
||||
case 'fontawesome':
|
||||
return (
|
||||
<FontAwesomeIcon
|
||||
name={name}
|
||||
style={style}
|
||||
size={size}
|
||||
/>
|
||||
);
|
||||
case 'foundation':
|
||||
return (
|
||||
<FoundationIcon
|
||||
name={name}
|
||||
style={style}
|
||||
size={size}
|
||||
/>
|
||||
);
|
||||
case 'ion':
|
||||
return (
|
||||
<IonIcon
|
||||
name={name}
|
||||
style={style}
|
||||
size={size}
|
||||
/>
|
||||
);
|
||||
case 'material':
|
||||
return (
|
||||
<MaterialIcon
|
||||
name={name}
|
||||
style={style}
|
||||
size={size}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
vectorIcon.propTypes = {
|
||||
name: PropTypes.string,
|
||||
type: PropTypes.string,
|
||||
size: PropTypes.number,
|
||||
style: Text.propTypes.style
|
||||
};
|
||||
|
||||
vectorIcon.defaultProps = {
|
||||
size: 14
|
||||
};
|
||||
|
|
|
|||
|
|
@ -201,10 +201,6 @@ class NotificationSettingsMentionsIos extends NotificationSettingsMentionsBase {
|
|||
let i18nId;
|
||||
let i18nMessage;
|
||||
switch (this.state.comments) {
|
||||
case 'any':
|
||||
i18nId = 'mobile.account_notifications.threads_start_participate';
|
||||
i18nMessage = 'Threads that I start or participate in';
|
||||
break;
|
||||
case 'root':
|
||||
i18nId = 'mobile.account_notifications.threads_start';
|
||||
i18nMessage = 'Threads that I start';
|
||||
|
|
@ -213,6 +209,11 @@ class NotificationSettingsMentionsIos extends NotificationSettingsMentionsBase {
|
|||
i18nId = 'mobile.account_notifications.threads_mentions';
|
||||
i18nMessage = 'Mentions in threads';
|
||||
break;
|
||||
case 'any':
|
||||
default:
|
||||
i18nId = 'mobile.account_notifications.threads_start_participate';
|
||||
i18nMessage = 'Threads that I start or participate in';
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -361,14 +361,15 @@ class NotificationSettingsMobileAndroid extends NotificationSettingsMobileBase {
|
|||
i18nId = 'user.settings.notifications.allActivity';
|
||||
i18nMessage = 'For all activity';
|
||||
break;
|
||||
case 'mention':
|
||||
i18nId = 'user.settings.notifications.onlyMentions';
|
||||
i18nMessage = 'Only for mentions and direct messages';
|
||||
break;
|
||||
case 'none':
|
||||
i18nId = 'user.settings.notifications.never';
|
||||
i18nMessage = 'Never';
|
||||
break;
|
||||
case 'mention':
|
||||
default:
|
||||
i18nId = 'user.settings.notifications.onlyMentions';
|
||||
i18nMessage = 'Only for mentions and direct messages';
|
||||
break;
|
||||
}
|
||||
props.description = (
|
||||
<FormattedText
|
||||
|
|
@ -412,10 +413,6 @@ class NotificationSettingsMobileAndroid extends NotificationSettingsMobileBase {
|
|||
let i18nId;
|
||||
let i18nMessage;
|
||||
switch (this.state.push_status) {
|
||||
case 'online':
|
||||
i18nId = 'user.settings.push_notification.online';
|
||||
i18nMessage = 'Online, away or offline';
|
||||
break;
|
||||
case 'away':
|
||||
i18nId = 'user.settings.push_notification.away';
|
||||
i18nMessage = 'Away or offline';
|
||||
|
|
@ -424,6 +421,11 @@ class NotificationSettingsMobileAndroid extends NotificationSettingsMobileBase {
|
|||
i18nId = 'user.settings.push_notification.offline';
|
||||
i18nMessage = 'Offline';
|
||||
break;
|
||||
case 'online':
|
||||
default:
|
||||
i18nId = 'user.settings.push_notification.online';
|
||||
i18nMessage = 'Online, away or offline';
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in a new issue