summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webapp/action_creators/global_actions.jsx8
-rw-r--r--webapp/components/root.jsx2
-rw-r--r--webapp/components/suggestion/search_suggestion_list.jsx1
-rw-r--r--webapp/components/user_settings/user_settings_modal.jsx14
-rw-r--r--webapp/components/user_settings/user_settings_theme.jsx13
5 files changed, 16 insertions, 22 deletions
diff --git a/webapp/action_creators/global_actions.jsx b/webapp/action_creators/global_actions.jsx
index ab38532a6..196d2b32c 100644
--- a/webapp/action_creators/global_actions.jsx
+++ b/webapp/action_creators/global_actions.jsx
@@ -264,6 +264,14 @@ export function newLocalizationSelected(locale) {
}
}
+export function loadBrowserLocale() {
+ let locale = (navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage)).split('-')[0];
+ if (!I18n.getLanguages()[locale]) {
+ locale = 'en';
+ }
+ return newLocalizationSelected(locale);
+}
+
export function viewLoggedIn() {
AsyncClient.getChannels();
AsyncClient.getChannelExtraInfo();
diff --git a/webapp/components/root.jsx b/webapp/components/root.jsx
index 9963bc5dd..3b85b23fd 100644
--- a/webapp/components/root.jsx
+++ b/webapp/components/root.jsx
@@ -69,7 +69,7 @@ export default class Root extends React.Component {
FastClick.attach(document.body);
// Get our localizaiton
- GlobalActions.newLocalizationSelected('en');
+ GlobalActions.loadBrowserLocale();
}
componentWillUnmount() {
LocalizationStore.removeChangeListener(this.localizationChanged);
diff --git a/webapp/components/suggestion/search_suggestion_list.jsx b/webapp/components/suggestion/search_suggestion_list.jsx
index b15cc4243..57aaee8ff 100644
--- a/webapp/components/suggestion/search_suggestion_list.jsx
+++ b/webapp/components/suggestion/search_suggestion_list.jsx
@@ -2,6 +2,7 @@
// See License.txt for license information.
import $ from 'jquery';
+import React from 'react';
import ReactDOM from 'react-dom';
import Constants from 'utils/constants.jsx';
import SuggestionList from './suggestion_list.jsx';
diff --git a/webapp/components/user_settings/user_settings_modal.jsx b/webapp/components/user_settings/user_settings_modal.jsx
index d1c1f0fe2..b71547baf 100644
--- a/webapp/components/user_settings/user_settings_modal.jsx
+++ b/webapp/components/user_settings/user_settings_modal.jsx
@@ -9,7 +9,6 @@ import SettingsSidebar from '../settings_sidebar.jsx';
import UserStore from 'stores/user_store.jsx';
import * as Utils from 'utils/utils.jsx';
-import Constants from 'utils/constants.jsx';
import {Modal} from 'react-bootstrap';
@@ -113,7 +112,6 @@ class UserSettingsModal extends React.Component {
return;
}
- this.resetTheme();
this.deactivateTab();
this.props.onModalDismissed();
return;
@@ -220,22 +218,10 @@ class UserSettingsModal extends React.Component {
if (!skipConfirm && this.requireConfirm) {
this.showConfirmModal(() => this.updateSection(section, true));
} else {
- if (this.state.active_section === 'theme' && section !== 'theme') {
- this.resetTheme();
- }
this.setState({active_section: section});
}
}
- resetTheme() {
- const user = UserStore.getCurrentUser();
- if (user.theme_props == null) {
- Utils.applyTheme(Constants.THEMES.default);
- } else {
- Utils.applyTheme(user.theme_props);
- }
- }
-
render() {
const {formatMessage} = this.props.intl;
if (this.state.currentUser == null) {
diff --git a/webapp/components/user_settings/user_settings_theme.jsx b/webapp/components/user_settings/user_settings_theme.jsx
index 3414fe2e2..14991037d 100644
--- a/webapp/components/user_settings/user_settings_theme.jsx
+++ b/webapp/components/user_settings/user_settings_theme.jsx
@@ -40,7 +40,6 @@ export default class ThemeSetting extends React.Component {
this.onChange = this.onChange.bind(this);
this.submitTheme = this.submitTheme.bind(this);
this.updateTheme = this.updateTheme.bind(this);
- this.deactivate = this.deactivate.bind(this);
this.resetFields = this.resetFields.bind(this);
this.handleImportModal = this.handleImportModal.bind(this);
@@ -62,12 +61,17 @@ export default class ThemeSetting extends React.Component {
}
}
componentWillReceiveProps(nextProps) {
- if (!this.props.selected && nextProps.selected) {
+ if (this.props.selected && !nextProps.selected) {
this.resetFields();
}
}
componentWillUnmount() {
UserStore.removeChangeListener(this.onChange);
+
+ if (this.props.selected) {
+ const state = this.getStateFromStores();
+ Utils.applyTheme(state.theme);
+ }
}
getStateFromStores() {
const user = UserStore.getCurrentUser();
@@ -147,11 +151,6 @@ export default class ThemeSetting extends React.Component {
updateType(type) {
this.setState({type});
}
- deactivate() {
- const state = this.getStateFromStores();
-
- Utils.applyTheme(state.theme);
- }
resetFields() {
const state = this.getStateFromStores();
state.serverError = null;