Merge branch 'announcement-sort' into 'main'

useAnnouncements: avoid toSorted

See merge request soapbox-pub/soapbox!3000
This commit is contained in:
Alex Gleason 2024-04-23 23:34:38 +00:00
commit b47b1666e7

View file

@ -85,11 +85,15 @@ const useAnnouncements = () => {
}); });
return { 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, ...result,
addReaction, addReaction,
removeReaction, 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 }; export { useAnnouncements };