mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 12:49:32 +00:00
fix: clean last notifications when visible = true
This commit is contained in:
@@ -317,16 +317,24 @@ const TicketsList = () => {
|
|||||||
const options = {
|
const options = {
|
||||||
body: `${data.message.body} - ${format(new Date(), "HH:mm")}`,
|
body: `${data.message.body} - ${format(new Date(), "HH:mm")}`,
|
||||||
icon: data.contact.profilePicUrl,
|
icon: data.contact.profilePicUrl,
|
||||||
|
tag: data.ticket.id,
|
||||||
};
|
};
|
||||||
let notification = new Notification(
|
let notification = new Notification(
|
||||||
`Mensagem de ${data.contact.name}`,
|
`Mensagem de ${data.contact.name}`,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|
||||||
notification.onclick = function (event) {
|
notification.onclick = function (event) {
|
||||||
event.preventDefault(); //
|
event.preventDefault(); //
|
||||||
window.open(`/chat/${data.ticket.id}`, "_self");
|
window.open(`/chat/${data.ticket.id}`, "_self");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
document.addEventListener("visibilitychange", () => {
|
||||||
|
if (document.visibilityState === "visible") {
|
||||||
|
notification.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById("sound").play();
|
document.getElementById("sound").play();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user