Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/lib/notification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
interface NotificationOptions {
title: string
body?: string
silent?: boolean
actions?: NotificationAction[]
onClick?: (event: Event) => void
onClose?: (event: Event) => void
}

export function notify({
title,
body,
silent,
actions,
onClick,
onClose,
}: NotificationOptions) {
const notification = new Notification(title, {
body,
silent,
actions,
})

if (onClick != null) {
notification.onclick = onClick
}
if (onClose != null) {
notification.onclose = onClose
}

return notification
}