Merge pull request #1956 from thelounge/xpaw/fix-notif-timestamp

Provide correct timestamp to browser notifications
This commit is contained in:
Jérémie Astori 2018-01-10 21:42:23 -05:00 committed by GitHub
commit 6cbc2eeef3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,13 +149,15 @@ function notifyMessage(targetId, channel, msg) {
body = cleanIrcMessage(msg.text); body = cleanIrcMessage(msg.text);
} }
const timestamp = Date.parse(msg.time);
try { try {
if (webpush.hasServiceWorker) { if (webpush.hasServiceWorker) {
navigator.serviceWorker.ready.then((registration) => { navigator.serviceWorker.ready.then((registration) => {
registration.active.postMessage({ registration.active.postMessage({
type: "notification", type: "notification",
chanId: targetId, chanId: targetId,
timestamp: msg.time, timestamp: timestamp,
title: title, title: title,
body: body, body: body,
}); });
@ -166,7 +168,7 @@ function notifyMessage(targetId, channel, msg) {
badge: "img/logo-64.png", badge: "img/logo-64.png",
icon: "img/touch-icon-192x192.png", icon: "img/touch-icon-192x192.png",
body: body, body: body,
timestamp: msg.time, timestamp: timestamp,
}); });
notify.addEventListener("click", function() { notify.addEventListener("click", function() {
window.focus(); window.focus();