diff --git a/api/context.go b/api/context.go index 41a52fa0cf..b91981ecd1 100644 --- a/api/context.go +++ b/api/context.go @@ -45,6 +45,7 @@ type Page struct { User *model.User Team *model.Team Channel *model.Channel + Preferences *model.Preferences PostID string SessionTokenIndex int64 Locale string diff --git a/web/react/pages/channel.jsx b/web/react/pages/channel.jsx index 1e28dab8b8..bfb95e1fcd 100644 --- a/web/react/pages/channel.jsx +++ b/web/react/pages/channel.jsx @@ -18,14 +18,8 @@ import RegisterAppModal from '../components/register_app_modal.jsx'; import ImportThemeModal from '../components/user_settings/import_theme_modal.jsx'; 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,12 +86,6 @@ 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) { if (props.PostId === '') { EventHelpers.emitChannelClickEvent(channel); @@ -105,11 +93,8 @@ global.window.setup_channel_page = function setup(props, team, channel) { EventHelpers.emitPostFocusEvent(props.PostId); } - PreferenceStore.addChangeListener(onPreferenceChange); - AsyncClient.getAllPreferences(); - ReactDOM.render( , 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 79eab4fe11..7ecaf0a95f 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; } - } } } diff --git a/web/templates/channel.html b/web/templates/channel.html index dcc50115b8..94d79a0227 100644 --- a/web/templates/channel.html +++ b/web/templates/channel.html @@ -6,7 +6,7 @@