From dc90ce46ae1f59adacfc2ec5f6c4aa55a13ca5eb Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 24 Nov 2017 18:25:21 -0500 Subject: [PATCH] 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 --- .../offline_indicator/offline_indicator.js | 1 + app/components/vector_icon.js | 104 +++++++++--------- .../notification_settings_mentions.android.js | 9 +- .../notification_settings_mobile.android.js | 18 +-- 4 files changed, 69 insertions(+), 63 deletions(-) diff --git a/app/components/offline_indicator/offline_indicator.js b/app/components/offline_indicator/offline_indicator.js index 8823db167..57b776abc 100644 --- a/app/components/offline_indicator/offline_indicator.js +++ b/app/components/offline_indicator/offline_indicator.js @@ -172,6 +172,7 @@ export default class OfflineIndicator extends Component { ); break; case CONNECTED: + default: i18nId = 'mobile.offlineIndicator.connected'; defaultMessage = 'Connected'; action = ( diff --git a/app/components/vector_icon.js b/app/components/vector_icon.js index c646f1637..f8cf18186 100644 --- a/app/components/vector_icon.js +++ b/app/components/vector_icon.js @@ -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 ( - - ); - case 'foundation': - return ( - - ); - case 'ion': - return ( - - ); - case 'material': - return ( - - ); + static defaultProps = { + size: 14 + }; + + render() { + const {name, type, style, size} = this.props; + + switch (type) { + case 'fontawesome': + return ( + + ); + case 'foundation': + return ( + + ); + case 'ion': + return ( + + ); + case 'material': + return ( + + ); + } + + return null; } - - return null; } - -vectorIcon.propTypes = { - name: PropTypes.string, - type: PropTypes.string, - size: PropTypes.number, - style: Text.propTypes.style -}; - -vectorIcon.defaultProps = { - size: 14 -}; diff --git a/app/screens/settings/notification_settings_mentions/notification_settings_mentions.android.js b/app/screens/settings/notification_settings_mentions/notification_settings_mentions.android.js index ae437d746..43384c356 100644 --- a/app/screens/settings/notification_settings_mentions/notification_settings_mentions.android.js +++ b/app/screens/settings/notification_settings_mentions/notification_settings_mentions.android.js @@ -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 ( diff --git a/app/screens/settings/notification_settings_mobile/notification_settings_mobile.android.js b/app/screens/settings/notification_settings_mobile/notification_settings_mobile.android.js index 946df2bd7..d82d9d1ba 100644 --- a/app/screens/settings/notification_settings_mobile/notification_settings_mobile.android.js +++ b/app/screens/settings/notification_settings_mobile/notification_settings_mobile.android.js @@ -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 = (