Merge branch 'initial-home-feed' into 'develop'
UI: fix the way initial data is loaded See merge request soapbox-pub/soapbox-fe!918
This commit is contained in:
commit
ec00f23d7e
|
@ -470,26 +470,10 @@ class UI extends React.PureComponent {
|
||||||
trailing: true,
|
trailing: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
componentDidMount() {
|
// Load initial data when a user is logged in
|
||||||
const { account, features, vapidKey, dispatch } = this.props;
|
loadAccountData = () => {
|
||||||
if (!account) return;
|
const { account, features, 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) {
|
|
||||||
dispatch(expandHomeTimeline());
|
dispatch(expandHomeTimeline());
|
||||||
|
|
||||||
dispatch(expandNotifications())
|
dispatch(expandNotifications())
|
||||||
|
@ -518,6 +502,28 @@ class UI extends React.PureComponent {
|
||||||
setTimeout(() => dispatch(fetchScheduledStatuses()), 900);
|
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());
|
dispatch(fetchCustomEmojis());
|
||||||
this.connectStreaming();
|
this.connectStreaming();
|
||||||
|
|
||||||
|
@ -531,7 +537,11 @@ class UI extends React.PureComponent {
|
||||||
|
|
||||||
const { dispatch, account, features, vapidKey } = this.props;
|
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());
|
dispatch(fetchChats());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue