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)

Этот коммит содержится в:
Jonathan
2017-08-09 16:33:31 -04:00
коммит произвёл Christopher Speller
родитель fd6856b674
Коммит 9309ad9d7a
2 изменённых файлов: 7 добавлений и 9 удалений

Просмотреть файл

@@ -16,18 +16,14 @@ export default class ManageLanguage extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.setupInitialState = this.setupInitialState.bind(this);
this.setLanguage = this.setLanguage.bind(this); this.setLanguage = this.setLanguage.bind(this);
this.changeLanguage = this.changeLanguage.bind(this); this.changeLanguage = this.changeLanguage.bind(this);
this.submitUser = this.submitUser.bind(this); this.submitUser = this.submitUser.bind(this);
this.state = this.setupInitialState(props); this.state = {
} locale: props.locale
setupInitialState(props) {
var user = props.user;
return {
locale: user.locale
}; };
} }
setLanguage(e) { setLanguage(e) {
this.setState({locale: e.target.value}); this.setState({locale: e.target.value});
} }
@@ -134,5 +130,6 @@ export default class ManageLanguage extends React.Component {
ManageLanguage.propTypes = { ManageLanguage.propTypes = {
user: PropTypes.object.isRequired, user: PropTypes.object.isRequired,
locale: PropTypes.string.isRequired,
updateSection: PropTypes.func.isRequired updateSection: PropTypes.func.isRequired
}; };

Просмотреть файл

@@ -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 (this.props.activeSection === 'languages') {
if (!I18n.isLanguageAvailable(userLocale)) { if (!I18n.isLanguageAvailable(userLocale)) {
this.props.user.locale = global.window.mm_config.DefaultClientLocale; userLocale = global.window.mm_config.DefaultClientLocale;
} }
languagesSection = ( languagesSection = (
<ManageLanguages <ManageLanguages
user={this.props.user} user={this.props.user}
locale={userLocale}
updateSection={(e) => { updateSection={(e) => {
this.updateSection(''); this.updateSection('');
e.preventDefault(); e.preventDefault();