useAnnouncements: avoid toSorted

This commit is contained in:
Alex Gleason 2024-04-23 18:05:51 -05:00
parent b8093ace04
commit 5f838b5e52
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

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 };