summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-01-05 08:24:26 -0600
committerCorey Hulen <corey@hulen.com>2016-01-05 08:24:26 -0600
commita35de266df1eb130572834ad31e3b8822284048c (patch)
tree6501b528a7ac8f4b976acb9453a02039ddd1e276
parent44dc4f2cac26dca6a88f1ed22b9729d640528768 (diff)
parenta9638df031366d27c2222e7306b205dbf8e2d508 (diff)
downloadchat-a35de266df1eb130572834ad31e3b8822284048c.tar.gz
chat-a35de266df1eb130572834ad31e3b8822284048c.tar.bz2
chat-a35de266df1eb130572834ad31e3b8822284048c.zip
Merge pull request #1804 from rgarmsen2295/plt-1536
PLT-1536 Fixed issue where font would not reset even after cancelling or exiting settings
-rw-r--r--web/react/components/user_settings/user_settings_display.jsx20
1 files changed, 13 insertions, 7 deletions
diff --git a/web/react/components/user_settings/user_settings_display.jsx b/web/react/components/user_settings/user_settings_display.jsx
index 96c3985d0..1ff0a2913 100644
--- a/web/react/components/user_settings/user_settings_display.jsx
+++ b/web/react/components/user_settings/user_settings_display.jsx
@@ -29,17 +29,16 @@ export default class UserSettingsDisplay extends React.Component {
this.handleNameRadio = this.handleNameRadio.bind(this);
this.handleFont = this.handleFont.bind(this);
this.updateSection = this.updateSection.bind(this);
+ this.updateState = this.updateState.bind(this);
+ this.deactivate = this.deactivate.bind(this);
this.state = getDisplayStateFromStores();
- this.selectedFont = this.state.selectedFont;
}
handleSubmit() {
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 fontPreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'selected_font', this.state.selectedFont);
- this.selectedFont = this.state.selectedFont;
-
savePreferences([timePreference, namePreference, fontPreference],
() => {
PreferenceStore.emitChange();
@@ -61,9 +60,19 @@ export default class UserSettingsDisplay extends React.Component {
this.setState({selectedFont});
}
updateSection(section) {
- this.setState(getDisplayStateFromStores());
+ this.updateState();
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() {
const serverError = this.state.serverError || null;
let clockSection;
@@ -266,9 +275,6 @@ export default class UserSettingsDisplay extends React.Component {
submit={this.handleSubmit}
server_error={serverError}
updateSection={(e) => {
- if (this.selectedFont !== this.state.selectedFont) {
- this.handleFont(this.selectedFont);
- }
this.updateSection('');
e.preventDefault();
}}