fix font not being changed on first page visit (if preferences havent been loaded before)

Этот коммит содержится в:
Florian Orben
2015-12-04 23:42:23 +01:00
родитель 1bee1e06e4
Коммит c440f253dd
2 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@@ -70,6 +70,7 @@ export default class ChannelLoader extends React.Component {
Utils.applyTheme(Constants.THEMES.default);
}
// if preferences have already been stored in local storage do not wait until preference store change is fired and handled in channel.jsx
const selectedFont = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'selected_font', {value: Constants.DEFAULT_FONT}).value;
Utils.applyFont(selectedFont);

Просмотреть файл

@@ -18,9 +18,20 @@ 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';
function onPreferenceChange() {
const selectedFont = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'selected_font', {value: Constants.DEFAULT_FONT}).value;
Utils.applyFont(selectedFont);
PreferenceStore.removeChangeListener(onPreferenceChange);
}
function setupChannelPage(props, team, channel) {
if (props.PostId === '') {
EventHelpers.emitChannelClickEvent(channel);
@@ -28,6 +39,7 @@ function setupChannelPage(props, team, channel) {
EventHelpers.emitPostFocusEvent(props.PostId);
}
PreferenceStore.addChangeListener(onPreferenceChange);
AsyncClient.getAllPreferences();
// ChannelLoader must be rendered first