diff --git a/src/api/hooks/announcements/useAnnouncements.ts b/src/api/hooks/announcements/useAnnouncements.ts index 3db0431e6..d8f4f0476 100644 --- a/src/api/hooks/announcements/useAnnouncements.ts +++ b/src/api/hooks/announcements/useAnnouncements.ts @@ -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 };