File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 13
13
14
14
$ : {
15
15
if ($query .data ?.announcements && $query .data .announcements .length > 0 ) {
16
- const announcement = $query .data .announcements [0 ];
17
- if (! $read_announcements .has (announcement .id )) {
16
+ const nonArchived = $query .data .announcements .filter ((a ) => ! a .archived_at );
17
+ const announcement = nonArchived [0 ];
18
+
19
+ if (announcement && ! $read_announcements .has (announcement .id )) {
18
20
latestUnreadAnnouncement = announcement ;
19
21
} else {
20
22
latestUnreadAnnouncement = undefined ;
21
23
}
22
24
}
23
25
}
24
26
25
- const handleClick = () =>
26
- latestUnreadAnnouncement && goto (` /announcements/${latestUnreadAnnouncement .id } ` );
27
+ function setAsRead() {
28
+ if (! latestUnreadAnnouncement ) return ;
29
+ $read_announcements .add (latestUnreadAnnouncement .id );
30
+ localStorage .setItem (' read_announcements' , JSON .stringify (Array .from ($read_announcements )));
31
+ latestUnreadAnnouncement = undefined ;
32
+ }
33
+
34
+ function handleClick() {
35
+ if (latestUnreadAnnouncement ) {
36
+ goto (` /announcements/${latestUnreadAnnouncement .id } ` );
37
+ setAsRead ();
38
+ }
39
+ }
27
40
28
41
function handleClose() {
29
42
if (latestUnreadAnnouncement && browser ) {
30
- $read_announcements .add (latestUnreadAnnouncement .id );
31
- localStorage .setItem (' read_announcements' , JSON .stringify (Array .from ($read_announcements )));
32
- latestUnreadAnnouncement = undefined ;
43
+ setAsRead ();
33
44
}
34
45
}
35
46
You can’t perform that action at this time.
0 commit comments