1
0
Fork 0

Fix noob mistake

And also make announcements and follow requests fetch more non-blocking
This commit is contained in:
Lim Chee Aun 2023-11-05 17:57:49 +08:00
parent 678fc100c8
commit 540b9a15a4

View file

@ -134,20 +134,25 @@ function Notifications({ columnMode }) {
(async () => { (async () => {
try { try {
const fetchNotificationsPromise = fetchNotifications(firstLoad); const fetchNotificationsPromise = fetchNotifications(firstLoad);
const fetchFollowRequestsPromise = fetchFollowRequests();
const fetchAnnouncementsPromise = fetchAnnouncements();
if (firstLoad) { if (firstLoad) {
const announcements = await fetchAnnouncementsPromise; fetchAnnouncements()
announcements.sort((a, b) => { .then((announcements) => {
// Sort by updatedAt first, then createdAt announcements.sort((a, b) => {
const aDate = new Date(a.updatedAt || a.createdAt); // Sort by updatedAt first, then createdAt
const bDate = new Date(b.updatedAt || b.createdAt); const aDate = new Date(a.updatedAt || a.createdAt);
return bDate - aDate; const bDate = new Date(b.updatedAt || b.createdAt);
}); return bDate - aDate;
setAnnouncements(announcements); });
const requests = await fetchFollowRequestsPromise; setAnnouncements(announcements);
setFollowRequests(requests); })
.catch(() => {});
fetchFollowRequests()
.then((requests) => {
setFollowRequests(requests);
})
.catch(() => {});
} }
const { done } = await fetchNotificationsPromise; const { done } = await fetchNotificationsPromise;