1
0
Fork 0

Make announcements appear faster

This commit is contained in:
Lim Chee Aun 2023-05-21 08:46:51 +08:00
parent 904e82872e
commit da46171ef6

View file

@ -103,14 +103,11 @@ function Notifications() {
setUIState('loading');
(async () => {
try {
const fetchNotificationsPromise = fetchNotifications(firstLoad);
const fetchFollowRequestsPromise = fetchFollowRequests();
const fetchAnnouncementsPromise = fetchAnnouncements();
const { done } = await fetchNotifications(firstLoad);
setShowMore(!done);
if (firstLoad) {
const requests = await fetchFollowRequestsPromise;
setFollowRequests(requests);
const announcements = await fetchAnnouncementsPromise;
announcements.sort((a, b) => {
// Sort by updatedAt first, then createdAt
@ -119,8 +116,13 @@ function Notifications() {
return bDate - aDate;
});
setAnnouncements(announcements);
const requests = await fetchFollowRequestsPromise;
setFollowRequests(requests);
}
const { done } = await fetchNotificationsPromise;
setShowMore(!done);
setUIState('default');
} catch (e) {
setUIState('error');