useAnnouncements: avoid toSorted
This commit is contained in:
parent
b8093ace04
commit
5f838b5e52
1 changed files with 5 additions and 1 deletions
|
@ -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 };
|
||||||
|
|
Loading…
Reference in a new issue