make pings send browser notifications

This commit is contained in:
maia arson crimew 2022-03-30 13:44:11 +02:00
parent 2197d2b757
commit 9a2ac1c432
1 changed files with 17 additions and 0 deletions

View File

@ -416,6 +416,23 @@ export const logEventToChat = async (event) => {
printChatMessage("ping", event.user, event.colour, messageContent); printChatMessage("ping", event.user, event.colour, messageContent);
beep(); beep();
if ("Notification" in window) {
const title = "watch party :)";
const options = {
body: event.data
? `${event.user} pinged saying: ${event.data}`
: `${event.user} pinged`,
};
if (Notification.permission === "granted") {
new Notification(title, options);
} else if (Notification.permission !== "denied") {
Notification.requestPermission().then(function (permission) {
if (permission === "granted") {
new Notification(title, options);
}
});
}
}
break; break;
} }
} }