Fixed issue where font would remain changed even after cancelling changes
Этот коммит содержится в:
@@ -29,17 +29,16 @@ export default class UserSettingsDisplay extends React.Component {
|
|||||||
this.handleNameRadio = this.handleNameRadio.bind(this);
|
this.handleNameRadio = this.handleNameRadio.bind(this);
|
||||||
this.handleFont = this.handleFont.bind(this);
|
this.handleFont = this.handleFont.bind(this);
|
||||||
this.updateSection = this.updateSection.bind(this);
|
this.updateSection = this.updateSection.bind(this);
|
||||||
|
this.updateState = this.updateState.bind(this);
|
||||||
|
this.deactivate = this.deactivate.bind(this);
|
||||||
|
|
||||||
this.state = getDisplayStateFromStores();
|
this.state = getDisplayStateFromStores();
|
||||||
this.selectedFont = this.state.selectedFont;
|
|
||||||
}
|
}
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
const timePreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time', this.state.militaryTime);
|
const timePreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time', this.state.militaryTime);
|
||||||
const namePreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', this.state.nameFormat);
|
const namePreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', this.state.nameFormat);
|
||||||
const fontPreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'selected_font', this.state.selectedFont);
|
const fontPreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'selected_font', this.state.selectedFont);
|
||||||
|
|
||||||
this.selectedFont = this.state.selectedFont;
|
|
||||||
|
|
||||||
savePreferences([timePreference, namePreference, fontPreference],
|
savePreferences([timePreference, namePreference, fontPreference],
|
||||||
() => {
|
() => {
|
||||||
PreferenceStore.emitChange();
|
PreferenceStore.emitChange();
|
||||||
@@ -61,9 +60,19 @@ export default class UserSettingsDisplay extends React.Component {
|
|||||||
this.setState({selectedFont});
|
this.setState({selectedFont});
|
||||||
}
|
}
|
||||||
updateSection(section) {
|
updateSection(section) {
|
||||||
this.setState(getDisplayStateFromStores());
|
this.updateState();
|
||||||
this.props.updateSection(section);
|
this.props.updateSection(section);
|
||||||
}
|
}
|
||||||
|
updateState() {
|
||||||
|
const newState = getDisplayStateFromStores();
|
||||||
|
if (!Utils.areObjectsEqual(newState, this.state)) {
|
||||||
|
this.handleFont(newState.selectedFont);
|
||||||
|
this.setState(newState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deactivate() {
|
||||||
|
this.updateState();
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
const serverError = this.state.serverError || null;
|
const serverError = this.state.serverError || null;
|
||||||
let clockSection;
|
let clockSection;
|
||||||
@@ -266,9 +275,6 @@ export default class UserSettingsDisplay extends React.Component {
|
|||||||
submit={this.handleSubmit}
|
submit={this.handleSubmit}
|
||||||
server_error={serverError}
|
server_error={serverError}
|
||||||
updateSection={(e) => {
|
updateSection={(e) => {
|
||||||
if (this.selectedFont !== this.state.selectedFont) {
|
|
||||||
this.handleFont(this.selectedFont);
|
|
||||||
}
|
|
||||||
this.updateSection('');
|
this.updateSection('');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}}
|
}}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user