summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan <jonfritz@gmail.com>2017-08-09 16:33:31 -0400
committerChristopher Speller <crspeller@gmail.com>2017-08-09 13:33:31 -0700
commit9309ad9d7a4684440234989f658c66bae3c1052f (patch)
tree09697333d71da77c399287a522517292afd5f3b1
parentfd6856b674cc24deb708f2cd36c247662ee10bc7 (diff)
downloadchat-9309ad9d7a4684440234989f658c66bae3c1052f.tar.gz
chat-9309ad9d7a4684440234989f658c66bae3c1052f.tar.bz2
chat-9309ad9d7a4684440234989f658c66bae3c1052f.zip
PLT-7301: Removed props mutation that was causing JS error, now passing locale as a prop directly instead of fetching it out of the user object (#7162)
-rw-r--r--webapp/components/user_settings/manage_languages.jsx11
-rw-r--r--webapp/components/user_settings/user_settings_display.jsx5
2 files changed, 7 insertions, 9 deletions
diff --git a/webapp/components/user_settings/manage_languages.jsx b/webapp/components/user_settings/manage_languages.jsx
index 2cb38068b..f83733c12 100644
--- a/webapp/components/user_settings/manage_languages.jsx
+++ b/webapp/components/user_settings/manage_languages.jsx
@@ -16,18 +16,14 @@ export default class ManageLanguage extends React.Component {
constructor(props) {
super(props);
- this.setupInitialState = this.setupInitialState.bind(this);
this.setLanguage = this.setLanguage.bind(this);
this.changeLanguage = this.changeLanguage.bind(this);
this.submitUser = this.submitUser.bind(this);
- this.state = this.setupInitialState(props);
- }
- setupInitialState(props) {
- var user = props.user;
- return {
- locale: user.locale
+ this.state = {
+ locale: props.locale
};
}
+
setLanguage(e) {
this.setState({locale: e.target.value});
}
@@ -134,5 +130,6 @@ export default class ManageLanguage extends React.Component {
ManageLanguage.propTypes = {
user: PropTypes.object.isRequired,
+ locale: PropTypes.string.isRequired,
updateSection: PropTypes.func.isRequired
};
diff --git a/webapp/components/user_settings/user_settings_display.jsx b/webapp/components/user_settings/user_settings_display.jsx
index aef82f229..74a939994 100644
--- a/webapp/components/user_settings/user_settings_display.jsx
+++ b/webapp/components/user_settings/user_settings_display.jsx
@@ -555,14 +555,15 @@ export default class UserSettingsDisplay extends React.Component {
);
}
- const userLocale = this.props.user.locale;
+ let userLocale = this.props.user.locale;
if (this.props.activeSection === 'languages') {
if (!I18n.isLanguageAvailable(userLocale)) {
- this.props.user.locale = global.window.mm_config.DefaultClientLocale;
+ userLocale = global.window.mm_config.DefaultClientLocale;
}
languagesSection = (
<ManageLanguages
user={this.props.user}
+ locale={userLocale}
updateSection={(e) => {
this.updateSection('');
e.preventDefault();