From 540b9a15a4e9a42ceff9712bed7567ff4ff712a4 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 5 Nov 2023 17:57:49 +0800 Subject: [PATCH] Fix noob mistake And also make announcements and follow requests fetch more non-blocking --- src/pages/notifications.jsx | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/pages/notifications.jsx b/src/pages/notifications.jsx index 0a25b72..6c48ec2 100644 --- a/src/pages/notifications.jsx +++ b/src/pages/notifications.jsx @@ -134,20 +134,25 @@ function Notifications({ columnMode }) { (async () => { try { const fetchNotificationsPromise = fetchNotifications(firstLoad); - const fetchFollowRequestsPromise = fetchFollowRequests(); - const fetchAnnouncementsPromise = fetchAnnouncements(); if (firstLoad) { - const announcements = await fetchAnnouncementsPromise; - announcements.sort((a, b) => { - // Sort by updatedAt first, then createdAt - const aDate = new Date(a.updatedAt || a.createdAt); - const bDate = new Date(b.updatedAt || b.createdAt); - return bDate - aDate; - }); - setAnnouncements(announcements); - const requests = await fetchFollowRequestsPromise; - setFollowRequests(requests); + fetchAnnouncements() + .then((announcements) => { + announcements.sort((a, b) => { + // Sort by updatedAt first, then createdAt + const aDate = new Date(a.updatedAt || a.createdAt); + const bDate = new Date(b.updatedAt || b.createdAt); + return bDate - aDate; + }); + setAnnouncements(announcements); + }) + .catch(() => {}); + + fetchFollowRequests() + .then((requests) => { + setFollowRequests(requests); + }) + .catch(() => {}); } const { done } = await fetchNotificationsPromise;