-
Couldn't load subscription status.
- Fork 11
fix: only toast unread notifications, not archived ones #1103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,6 +42,12 @@ const { onResult: onNotificationAdded } = useSubscription(notificationAddedSubsc | |||||||||||||||
| onNotificationAdded(({ data }) => { | ||||||||||||||||
| if (!data) return; | ||||||||||||||||
| const notif = useFragment(NOTIFICATION_FRAGMENT, data.notificationAdded); | ||||||||||||||||
| if (notif.type !== NotificationType.Unread) return; | ||||||||||||||||
| // probably smart to leave this log outside the if-block for the initial release | ||||||||||||||||
| console.log('incoming notification', notif); | ||||||||||||||||
| if (!globalThis.toast) { | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+48
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your error handling would make a junior developer cry! A silent return when Add proper error handling: if (!globalThis.toast) {
+ console.error('Toast notification system not initialized');
return;
}📝 Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thoughts yall? @elibosley @mdatelle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would error here so users can see what is happening. |
||||||||||||||||
|
|
||||||||||||||||
| const funcMapping: Record<Importance, (typeof globalThis)['toast']['info' | 'error' | 'warning']> = { | ||||||||||||||||
| [Importance.Alert]: globalThis.toast.error, | ||||||||||||||||
|
|
@@ -51,10 +57,12 @@ onNotificationAdded(({ data }) => { | |||||||||||||||
| const toast = funcMapping[notif.importance]; | ||||||||||||||||
| const createOpener = () => ({ label: 'Open', onClick: () => location.assign(notif.link as string) }); | ||||||||||||||||
|
|
||||||||||||||||
| toast(notif.title, { | ||||||||||||||||
| description: notif.subject, | ||||||||||||||||
| action: notif.link ? createOpener() : undefined, | ||||||||||||||||
| }); | ||||||||||||||||
| requestAnimationFrame(() => | ||||||||||||||||
| toast(notif.title, { | ||||||||||||||||
| description: notif.subject, | ||||||||||||||||
| action: notif.link ? createOpener() : undefined, | ||||||||||||||||
| }) | ||||||||||||||||
| ); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| const overview = computed(() => { | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.