diff options
| author | Beebles <102569435+beebls@users.noreply.github.com> | 2024-09-13 18:46:49 -0600 |
|---|---|---|
| committer | Beebles <102569435+beebls@users.noreply.github.com> | 2024-09-13 18:46:49 -0600 |
| commit | 2384f6c40ec26724199a9e9f05efa6ed02296bbc (patch) | |
| tree | 699374f0368413d5067f63756eb2439199519b34 | |
| parent | ab3b69ffed5266b82936e3935fec70e3da5db939 (diff) | |
| download | decky-loader-beebls/motd-backup.tar.gz decky-loader-beebls/motd-backup.zip | |
ensure nulls arent passed to sortbeebls/motd-backup
| -rw-r--r-- | frontend/src/components/AnnouncementsDisplay.tsx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/frontend/src/components/AnnouncementsDisplay.tsx b/frontend/src/components/AnnouncementsDisplay.tsx index 4ba813de..c6e6db1e 100644 --- a/frontend/src/components/AnnouncementsDisplay.tsx +++ b/frontend/src/components/AnnouncementsDisplay.tsx @@ -38,11 +38,16 @@ export function AnnouncementsDisplay() { setAnnouncements((oldAnnouncements) => { const newArr = [...oldAnnouncements, ...newAnnouncements]; const setOfIds = new Set(newArr.map((a) => a.id)); - return Array.from(setOfIds) - .map((id) => newArr.find((a) => a.id === id)!) - .sort((a, b) => { + return ( + ( + Array.from(setOfIds) + .map((id) => newArr.find((a) => a.id === id)) + // Typescript doesn't type filter(Boolean) correctly, so I have to assert this + .filter(Boolean) as Announcement[] + ).sort((a, b) => { return new Date(b.created).getTime() - new Date(a.created).getTime(); - }); + }) + ); }); } |
