Merge branch 'initial-home-feed' into 'develop'

UI: fix the way initial data is loaded

See merge request soapbox-pub/soapbox-fe!918
merge-requests/920/merge
Alex Gleason 3 years ago
commit ec00f23d7e

@ -470,26 +470,10 @@ class UI extends React.PureComponent {
trailing: true,
});
componentDidMount() {
const { account, features, vapidKey, dispatch } = this.props;
if (!account) return;
window.addEventListener('resize', this.handleResize, { passive: true });
document.addEventListener('dragenter', this.handleDragEnter, false);
document.addEventListener('dragover', this.handleDragOver, false);
document.addEventListener('drop', this.handleDrop, false);
document.addEventListener('dragleave', this.handleDragLeave, false);
document.addEventListener('dragend', this.handleDragEnd, false);
// Load initial data when a user is logged in
loadAccountData = () => {
const { account, features, dispatch } = this.props;
if ('serviceWorker' in navigator) {
navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerPostMessage);
}
if (typeof window.Notification !== 'undefined' && Notification.permission === 'default') {
window.setTimeout(() => Notification.requestPermission(), 120 * 1000);
}
if (account) {
dispatch(expandHomeTimeline());
dispatch(expandNotifications())
@ -518,6 +502,28 @@ class UI extends React.PureComponent {
setTimeout(() => dispatch(fetchScheduledStatuses()), 900);
}
componentDidMount() {
const { account, vapidKey, dispatch } = this.props;
window.addEventListener('resize', this.handleResize, { passive: true });
document.addEventListener('dragenter', this.handleDragEnter, false);
document.addEventListener('dragover', this.handleDragOver, false);
document.addEventListener('drop', this.handleDrop, false);
document.addEventListener('dragleave', this.handleDragLeave, false);
document.addEventListener('dragend', this.handleDragEnd, false);
if ('serviceWorker' in navigator) {
navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerPostMessage);
}
if (typeof window.Notification !== 'undefined' && Notification.permission === 'default') {
window.setTimeout(() => Notification.requestPermission(), 120 * 1000);
}
if (account) {
this.loadAccountData();
}
dispatch(fetchCustomEmojis());
this.connectStreaming();
@ -531,7 +537,11 @@ class UI extends React.PureComponent {
const { dispatch, account, features, vapidKey } = this.props;
if (features.chats && account && !prevProps.features.chats) {
// The user has logged in
if (account && !prevProps.account) {
this.loadAccountData();
// The instance has loaded
} else if (account && features.chats && !prevProps.features.chats) {
dispatch(fetchChats());
}

Loading…
Cancel
Save