diff --git a/src/layout/Announcements/AnnouncementCard.svelte b/src/layout/Announcements/AnnouncementCard.svelte index 006797a9..807bdce6 100644 --- a/src/layout/Announcements/AnnouncementCard.svelte +++ b/src/layout/Announcements/AnnouncementCard.svelte @@ -13,8 +13,23 @@ let showContent = false; let read: boolean; + function isAnnouncementRead(): boolean { + return (localStorage.getItem('read_announcements') ?? '').split(',').includes(String(id)); + } + + function setAnnouncementRead() { + const ids = (localStorage.getItem('read_announcements') ?? '').split(',').filter((id) => !!id); + if (!ids.includes(String(id))) + localStorage.setItem('read_announcements', ids.concat(String(id)).join(',')); + } + + const showAnnouncement = () => { + showContent = true; + setAnnouncementRead(); + }; + onMount(() => { - read = (localStorage.getItem('read_announcements') as string).split(',').includes(String(id)); + read = isAnnouncementRead(); }); @@ -35,7 +50,7 @@ {#if $$slots.channel}