diff --git a/app/components/root/index.js b/app/components/root/index.js index befcce969..c2234531c 100644 --- a/app/components/root/index.js +++ b/app/components/root/index.js @@ -3,7 +3,6 @@ import {connect} from 'react-redux'; -import {Client4} from 'mattermost-redux/client'; import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentUrl} from 'mattermost-redux/selectors/entities/general'; @@ -15,7 +14,6 @@ import Root from './root'; function mapStateToProps(state) { const locale = getCurrentLocale(state); - Client4.setAcceptLanguage(locale); return { theme: getTheme(state), diff --git a/app/components/root/root.js b/app/components/root/root.js index 5617fd42d..bb202968b 100644 --- a/app/components/root/root.js +++ b/app/components/root/root.js @@ -6,6 +6,7 @@ import PropTypes from 'prop-types'; import {IntlProvider} from 'react-intl'; import {Platform} from 'react-native'; +import {Client4} from 'mattermost-redux/client'; import EventEmitter from 'mattermost-redux/utils/event_emitter'; import {NavigationTypes, ViewTypes} from 'app/constants'; @@ -23,6 +24,8 @@ export default class Root extends PureComponent { }; componentWillMount() { + Client4.setAcceptLanguage(this.props.locale); + if (!this.props.excludeEvents) { EventEmitter.on(ViewTypes.NOTIFICATION_IN_APP, this.handleInAppNotification); EventEmitter.on(ViewTypes.NOTIFICATION_TAPPED, this.handleNotificationTapped); @@ -30,6 +33,12 @@ export default class Root extends PureComponent { } } + componentDidUpdate(prevProps) { + if (prevProps.locale !== this.props.locale) { + Client4.setAcceptLanguage(this.props.locale); + } + } + componentWillUnmount() { if (!this.props.excludeEvents) { EventEmitter.off(ViewTypes.NOTIFICATION_IN_APP, this.handleInAppNotification);