Forum notifications
This commit is contained in:
parent
c4bc17ae7f
commit
1fd9c284de
@ -44,6 +44,8 @@ component Settings(user *arn.User)
|
|||||||
Icon("paper-plane")
|
Icon("paper-plane")
|
||||||
span Send test notification
|
span Send test notification
|
||||||
|
|
||||||
|
p Notifications are currently used for forum replies only.
|
||||||
|
|
||||||
.widget.mountable
|
.widget.mountable
|
||||||
h3.widget-title
|
h3.widget-title
|
||||||
Icon("user-plus")
|
Icon("user-plus")
|
||||||
|
@ -145,7 +145,8 @@ self.addEventListener("push", (evt: PushEvent) => {
|
|||||||
(self as any).registration.showNotification(payload.title, {
|
(self as any).registration.showNotification(payload.title, {
|
||||||
body: payload.message,
|
body: payload.message,
|
||||||
icon: payload.icon,
|
icon: payload.icon,
|
||||||
image: payload.image
|
image: payload.image,
|
||||||
|
data: payload.link
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -155,12 +156,18 @@ self.addEventListener("pushsubscriptionchange", (evt: any) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
self.addEventListener("notificationclick", (evt: NotificationEvent) => {
|
self.addEventListener("notificationclick", (evt: NotificationEvent) => {
|
||||||
console.log(evt)
|
let notification = evt.notification
|
||||||
|
notification.close()
|
||||||
evt.notification.close()
|
|
||||||
|
|
||||||
evt.waitUntil(
|
evt.waitUntil(
|
||||||
(self as any).clients.matchAll().then(function(clientList) {
|
(self as any).clients.matchAll().then(function(clientList) {
|
||||||
|
// If we have a link, use that link to open a new window.
|
||||||
|
let url = notification.data
|
||||||
|
|
||||||
|
if(url) {
|
||||||
|
return (self as any).clients.openWindow(url)
|
||||||
|
}
|
||||||
|
|
||||||
// If there is at least one client, focus it.
|
// If there is at least one client, focus it.
|
||||||
if(clientList.length > 0) {
|
if(clientList.length > 0) {
|
||||||
return clientList[0].focus()
|
return clientList[0].focus()
|
||||||
|
Loading…
Reference in New Issue
Block a user