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) {
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
};

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

@@ -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();