Merge pull request #2534 from hmhealey/plt2184
PLT-2184 Moved theme reset code to componentWillUnmount
Этот коммит содержится в:
@@ -9,7 +9,6 @@ import SettingsSidebar from '../settings_sidebar.jsx';
|
|||||||
|
|
||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import Constants from 'utils/constants.jsx';
|
|
||||||
|
|
||||||
import {Modal} from 'react-bootstrap';
|
import {Modal} from 'react-bootstrap';
|
||||||
|
|
||||||
@@ -113,7 +112,6 @@ class UserSettingsModal extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetTheme();
|
|
||||||
this.deactivateTab();
|
this.deactivateTab();
|
||||||
this.props.onModalDismissed();
|
this.props.onModalDismissed();
|
||||||
return;
|
return;
|
||||||
@@ -220,22 +218,10 @@ class UserSettingsModal extends React.Component {
|
|||||||
if (!skipConfirm && this.requireConfirm) {
|
if (!skipConfirm && this.requireConfirm) {
|
||||||
this.showConfirmModal(() => this.updateSection(section, true));
|
this.showConfirmModal(() => this.updateSection(section, true));
|
||||||
} else {
|
} else {
|
||||||
if (this.state.active_section === 'theme' && section !== 'theme') {
|
|
||||||
this.resetTheme();
|
|
||||||
}
|
|
||||||
this.setState({active_section: section});
|
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() {
|
render() {
|
||||||
const {formatMessage} = this.props.intl;
|
const {formatMessage} = this.props.intl;
|
||||||
if (this.state.currentUser == null) {
|
if (this.state.currentUser == null) {
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ export default class ThemeSetting extends React.Component {
|
|||||||
this.onChange = this.onChange.bind(this);
|
this.onChange = this.onChange.bind(this);
|
||||||
this.submitTheme = this.submitTheme.bind(this);
|
this.submitTheme = this.submitTheme.bind(this);
|
||||||
this.updateTheme = this.updateTheme.bind(this);
|
this.updateTheme = this.updateTheme.bind(this);
|
||||||
this.deactivate = this.deactivate.bind(this);
|
|
||||||
this.resetFields = this.resetFields.bind(this);
|
this.resetFields = this.resetFields.bind(this);
|
||||||
this.handleImportModal = this.handleImportModal.bind(this);
|
this.handleImportModal = this.handleImportModal.bind(this);
|
||||||
|
|
||||||
@@ -62,12 +61,17 @@ export default class ThemeSetting extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (!this.props.selected && nextProps.selected) {
|
if (this.props.selected && !nextProps.selected) {
|
||||||
this.resetFields();
|
this.resetFields();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
UserStore.removeChangeListener(this.onChange);
|
UserStore.removeChangeListener(this.onChange);
|
||||||
|
|
||||||
|
if (this.props.selected) {
|
||||||
|
const state = this.getStateFromStores();
|
||||||
|
Utils.applyTheme(state.theme);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
getStateFromStores() {
|
getStateFromStores() {
|
||||||
const user = UserStore.getCurrentUser();
|
const user = UserStore.getCurrentUser();
|
||||||
@@ -147,11 +151,6 @@ export default class ThemeSetting extends React.Component {
|
|||||||
updateType(type) {
|
updateType(type) {
|
||||||
this.setState({type});
|
this.setState({type});
|
||||||
}
|
}
|
||||||
deactivate() {
|
|
||||||
const state = this.getStateFromStores();
|
|
||||||
|
|
||||||
Utils.applyTheme(state.theme);
|
|
||||||
}
|
|
||||||
resetFields() {
|
resetFields() {
|
||||||
const state = this.getStateFromStores();
|
const state = this.getStateFromStores();
|
||||||
state.serverError = null;
|
state.serverError = null;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user