From da46171ef6c1649a3cc7592a8aaad498de82b707 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 21 May 2023 08:46:51 +0800 Subject: [PATCH] Make announcements appear faster --- src/pages/notifications.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/notifications.jsx b/src/pages/notifications.jsx index 6ece5c3c..305ef5f0 100644 --- a/src/pages/notifications.jsx +++ b/src/pages/notifications.jsx @@ -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');