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