From: Ernest Date: Sun, 24 Jul 2022 12:08:23 +0000 (+0200) Subject: Fix Notification browser fetch X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/%7BrepoUrl%7D?a=commitdiff_plain;h=982fae53c89ea1fab142e602d600217435b1624e;p=lemmy-ui.git Fix Notification browser fetch --- diff --git a/src/shared/utils.ts b/src/shared/utils.ts index f54e259..f9c554f 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -686,21 +686,18 @@ export function notifyPrivateMessage(pmv: PrivateMessageView, router: any) { function notify(info: NotifyInfo, router: any) { messageToastify(info, router); - // TODO absolute nightmare bug, but notifs are currently broken. - // Notification.new will try to do a browser fetch ??? - - // if (Notification.permission !== "granted") Notification.requestPermission(); - // else { - // var notification = new Notification(info.name, { - // icon: info.icon, - // body: info.body, - // }); - - // notification.onclick = (ev: Event): any => { - // ev.preventDefault(); - // router.history.push(info.link); - // }; - // } + if (Notification.permission !== "granted") Notification.requestPermission(); + else { + var notification = new Notification(info.name, { + ...{body: info.body}, + ...(info.icon && {icon: info.icon}) + }); + + notification.onclick = (ev: Event): any => { + ev.preventDefault(); + router.history.push(info.link); + }; + } } export function setupTribute() {