This commit is contained in:
Nicolas Mowen 2024-07-20 15:08:48 -06:00
parent fa8a0cc5fc
commit 367555ba98
4 changed files with 8 additions and 9 deletions

View File

@ -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()}"
message = f"Detected on {payload['after']['camera'].replace('_', ' ').title()}"
direct_url = f"/review?id={reviewId}"
link = f"/review?id={reviewId}"
image = f'{payload["after"]["thumb_path"].replace("/media/frigate", "")}'
for pusher in self.web_pushers:
@ -101,7 +101,7 @@ class WebPushClient(Communicator): # type: ignore[misc]
{
"title": title,
"message": message,
"direct_url": direct_url,
"link": link,
"image": image,
"id": reviewId,
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -28,10 +28,9 @@ self.addEventListener("notificationclick", (event) => {
// @ts-expect-error we know this exists
if (event.notification.data) {
// @ts-expect-error we know this exists
const url = event.notification.data.link;
// @ts-expect-error we know this exists
// eslint-disable-next-line no-undef
clients.matchAll({ type: "window" }).then((windowClients) => {
// Check if there is already a window/tab open with the target URL
for (let i = 0; i < windowClients.length; i++) {
@ -42,9 +41,9 @@ self.addEventListener("notificationclick", (event) => {
}
}
// If not, then open the target URL in a new window/tab.
// @ts-expect-error we know this exists
// eslint-disable-next-line no-undef
if (clients.openWindow) {
// @ts-expect-error we know this exists
// eslint-disable-next-line no-undef
return clients.openWindow(url);
}
});

View File

@ -25,7 +25,7 @@ import { toast } from "sonner";
import useSWR from "swr";
import { z } from "zod";
const NOTIFICATION_SERVICE_WORKER = "notifications-worker.ts";
const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js";
type NotificationSettingsValueType = {
enabled: boolean;
@ -220,11 +220,11 @@ export default function NotificationView({
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Loitering Time</FormLabel>
<FormLabel>Email</FormLabel>
<FormControl>
<Input
className="w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]"
placeholder="0"
placeholder="example@email.com"
{...field}
/>
</FormControl>