diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2016-01-25 10:40:29 -0500 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2016-01-26 13:50:57 -0500 |
commit | a6c97490b3c6b7bca00d16bc436abf902ee7b101 (patch) | |
tree | a166fd4ce0ae1586a3fa8bf3903ce057b72767ef /web/react | |
parent | 163bab98b5662b34515c70ecb86ea625742b9fea (diff) | |
download | chat-a6c97490b3c6b7bca00d16bc436abf902ee7b101.tar.gz chat-a6c97490b3c6b7bca00d16bc436abf902ee7b101.tar.bz2 chat-a6c97490b3c6b7bca00d16bc436abf902ee7b101.zip |
Changed first preference load to be done synchronously
Diffstat (limited to 'web/react')
-rw-r--r-- | web/react/pages/channel.jsx | 17 | ||||
-rw-r--r-- | web/react/stores/preference_store.jsx | 21 |
2 files changed, 15 insertions, 23 deletions
diff --git a/web/react/pages/channel.jsx b/web/react/pages/channel.jsx index 1e28dab8b..5bb0294fd 100644 --- a/web/react/pages/channel.jsx +++ b/web/react/pages/channel.jsx @@ -20,12 +20,8 @@ import InviteMemberModal from '../components/invite_member_modal.jsx'; import PreferenceStore from '../stores/preference_store.jsx'; -import * as Utils from '../utils/utils.jsx'; -import * as AsyncClient from '../utils/async_client.jsx'; import * as EventHelpers from '../dispatcher/event_helpers.jsx'; -import Constants from '../utils/constants.jsx'; - var IntlProvider = ReactIntl.IntlProvider; class Root extends React.Component { @@ -92,24 +88,17 @@ class Root extends React.Component { } } -function onPreferenceChange() { - const selectedFont = PreferenceStore.get(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'selected_font', Constants.DEFAULT_FONT); - Utils.applyFont(selectedFont); - PreferenceStore.removeChangeListener(onPreferenceChange); -} - -global.window.setup_channel_page = function setup(props, team, channel) { +global.window.setup_channel_page = function setup(props, team, channel, preferences) { if (props.PostId === '') { EventHelpers.emitChannelClickEvent(channel); } else { EventHelpers.emitPostFocusEvent(props.PostId); } - PreferenceStore.addChangeListener(onPreferenceChange); - AsyncClient.getAllPreferences(); + PreferenceStore.setPreferences(preferences); ReactDOM.render( <Root map={props} />, document.getElementById('channel_view') ); -};
\ No newline at end of file +}; diff --git a/web/react/stores/preference_store.jsx b/web/react/stores/preference_store.jsx index 79eab4fe1..7ecaf0a95 100644 --- a/web/react/stores/preference_store.jsx +++ b/web/react/stores/preference_store.jsx @@ -133,6 +133,16 @@ class PreferenceStoreClass extends EventEmitter { return preference; } + setPreferences(newPreferences) { + const preferences = this.getAllPreferences(); + + for (const preference of newPreferences) { + preferences.set(getPreferenceKeyForModel(preference), preference); + } + + this.setAllPreferences(preferences); + } + emitChange() { this.emit(CHANGE_EVENT); } @@ -155,18 +165,11 @@ class PreferenceStoreClass extends EventEmitter { this.emitChange(); break; } - case ActionTypes.RECIEVED_PREFERENCES: { - const preferences = this.getAllPreferences(); - - for (const preference of action.preferences) { - preferences.set(getPreferenceKeyForModel(preference), preference); - } - - this.setAllPreferences(preferences); + case ActionTypes.RECIEVED_PREFERENCES: + this.setPreferences(action.preferences); this.emitChange(); break; } - } } } |