mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-13 06:35:24 +03:00
Always open notification
This commit is contained in:
parent
367555ba98
commit
c92c8256b1
@ -90,7 +90,7 @@ class WebPushClient(Communicator): # type: ignore[misc]
|
|||||||
|
|
||||||
title = f"{', '.join(sorted_objects).replace('_', ' ').title()}{' was' if state == 'end' else ''} detected in {', '.join(payload['after']['data']['zones']).replace('_', ' ').title()}"
|
title = f"{', '.join(sorted_objects).replace('_', ' ').title()}{' was' if state == 'end' else ''} detected in {', '.join(payload['after']['data']['zones']).replace('_', ' ').title()}"
|
||||||
message = f"Detected on {payload['after']['camera'].replace('_', ' ').title()}"
|
message = f"Detected on {payload['after']['camera'].replace('_', ' ').title()}"
|
||||||
link = f"/review?id={reviewId}"
|
direct_url = f"/review?id={reviewId}"
|
||||||
image = f'{payload["after"]["thumb_path"].replace("/media/frigate", "")}'
|
image = f'{payload["after"]["thumb_path"].replace("/media/frigate", "")}'
|
||||||
|
|
||||||
for pusher in self.web_pushers:
|
for pusher in self.web_pushers:
|
||||||
@ -101,7 +101,7 @@ class WebPushClient(Communicator): # type: ignore[misc]
|
|||||||
{
|
{
|
||||||
"title": title,
|
"title": title,
|
||||||
"message": message,
|
"message": message,
|
||||||
"link": link,
|
"direct_url": direct_url,
|
||||||
"image": image,
|
"image": image,
|
||||||
"id": reviewId,
|
"id": reviewId,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,24 +29,11 @@ self.addEventListener("notificationclick", (event) => {
|
|||||||
// @ts-expect-error we know this exists
|
// @ts-expect-error we know this exists
|
||||||
if (event.notification.data) {
|
if (event.notification.data) {
|
||||||
const url = event.notification.data.link;
|
const url = event.notification.data.link;
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
clients.matchAll({ type: "window" }).then((windowClients) => {
|
if (clients.openWindow) {
|
||||||
// Check if there is already a window/tab open with the target URL
|
|
||||||
for (let i = 0; i < windowClients.length; i++) {
|
|
||||||
const client = windowClients[i];
|
|
||||||
// If so, just focus it.
|
|
||||||
if (client.url === url && "focus" in client) {
|
|
||||||
return client.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If not, then open the target URL in a new window/tab.
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
if (clients.openWindow) {
|
return clients.openWindow(url);
|
||||||
// eslint-disable-next-line no-undef
|
}
|
||||||
return clients.openWindow(url);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user