Changed first preference load to be done synchronously
Этот коммит содержится в:
@@ -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')
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user