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