From 5b0beb8b9c1212ad8fabe8293d16f5551eca5b14 Mon Sep 17 00:00:00 2001 From: canove Date: Tue, 28 Jul 2020 17:03:33 -0300 Subject: [PATCH] improvement: open ticket on notification click --- frontend/src/components/TicketsList/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/TicketsList/index.js b/frontend/src/components/TicketsList/index.js index 3464c18..e7459ed 100644 --- a/frontend/src/components/TicketsList/index.js +++ b/frontend/src/components/TicketsList/index.js @@ -308,12 +308,23 @@ const TicketsList = () => { }); }; + // let notification; + const showDesktopNotification = data => { + console.log(data); const options = { body: `${data.message.body} - ${format(new Date(), "HH:mm")}`, icon: data.contact.profilePicUrl, }; - new Notification(`Mensagem de ${data.contact.name}`, options); + let notification = new Notification( + `Mensagem de ${data.contact.name}`, + options + ); + notification.onclick = function (event) { + event.preventDefault(); // + window.open(`/chat/${data.ticket.id}`, "_blank"); + }; + document.getElementById("sound").play(); };