From 31c33e43d51ef85e78f3c5e68cc3e4b9cded06c1 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 9 Jan 2018 18:47:13 +0200 Subject: [PATCH] Provide correct timestamp to browser notifications --- client/js/socket-events/msg.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/js/socket-events/msg.js b/client/js/socket-events/msg.js index 30280a1c..dea50413 100644 --- a/client/js/socket-events/msg.js +++ b/client/js/socket-events/msg.js @@ -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();