UI: fix the way initial data is loaded
This commit is contained in:
parent
e2df6eff8b
commit
e283afe191
|
@ -470,9 +470,40 @@ class UI extends React.PureComponent {
|
||||||
trailing: true,
|
trailing: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Load initial data when a user is logged in
|
||||||
|
loadAccountData = () => {
|
||||||
|
const { account, features, dispatch } = this.props;
|
||||||
|
|
||||||
|
dispatch(expandHomeTimeline());
|
||||||
|
|
||||||
|
dispatch(expandNotifications())
|
||||||
|
.then(() => dispatch(fetchMarker(['notifications'])))
|
||||||
|
.catch(console.error);
|
||||||
|
|
||||||
|
if (features.chats) {
|
||||||
|
dispatch(fetchChats());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isStaff(account)) {
|
||||||
|
dispatch(fetchReports({ state: 'open' }));
|
||||||
|
dispatch(fetchUsers(['local', 'need_approval']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAdmin(account)) {
|
||||||
|
dispatch(fetchConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => dispatch(fetchFilters()), 500);
|
||||||
|
|
||||||
|
if (account.get('locked')) {
|
||||||
|
setTimeout(() => dispatch(fetchFollowRequests()), 700);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => dispatch(fetchScheduledStatuses()), 900);
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { account, features, vapidKey, dispatch } = this.props;
|
const { account, vapidKey, dispatch } = this.props;
|
||||||
if (!account) return;
|
|
||||||
|
|
||||||
window.addEventListener('resize', this.handleResize, { passive: true });
|
window.addEventListener('resize', this.handleResize, { passive: true });
|
||||||
document.addEventListener('dragenter', this.handleDragEnter, false);
|
document.addEventListener('dragenter', this.handleDragEnter, false);
|
||||||
|
@ -490,32 +521,7 @@ class UI extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account) {
|
if (account) {
|
||||||
dispatch(expandHomeTimeline());
|
this.loadAccountData();
|
||||||
|
|
||||||
dispatch(expandNotifications())
|
|
||||||
.then(() => dispatch(fetchMarker(['notifications'])))
|
|
||||||
.catch(console.error);
|
|
||||||
|
|
||||||
if (features.chats) {
|
|
||||||
dispatch(fetchChats());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isStaff(account)) {
|
|
||||||
dispatch(fetchReports({ state: 'open' }));
|
|
||||||
dispatch(fetchUsers(['local', 'need_approval']));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isAdmin(account)) {
|
|
||||||
dispatch(fetchConfig());
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => dispatch(fetchFilters()), 500);
|
|
||||||
|
|
||||||
if (account.get('locked')) {
|
|
||||||
setTimeout(() => dispatch(fetchFollowRequests()), 700);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => dispatch(fetchScheduledStatuses()), 900);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(fetchCustomEmojis());
|
dispatch(fetchCustomEmojis());
|
||||||
|
@ -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