Merge branch 'announcement-sort' into 'main'

useAnnouncements: avoid toSorted

See merge request soapbox-pub/soapbox!3000
environments/review-main-yi2y9f/deployments/4565
Alex Gleason 2024-04-23 23:34:38 +00:00
commit b47b1666e7
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -85,11 +85,15 @@ const useAnnouncements = () => {
});
return {
data: data?.toSorted((a, b) => new Date(a.starts_at || a.published_at).getDate() - new Date(b.starts_at || b.published_at).getDate()),
data: data ? [...data].sort(compareAnnouncements) : undefined,
...result,
addReaction,
removeReaction,
};
};
function compareAnnouncements(a: Announcement, b: Announcement): number {
return new Date(a.starts_at || a.published_at).getDate() - new Date(b.starts_at || b.published_at).getDate();
}
export { useAnnouncements };