import { Button } from "@/components/ui/button"; import Heading from "@/components/ui/heading"; import { Label } from "@/components/ui/label"; import { Toaster } from "@/components/ui/sonner"; import { Switch } from "@/components/ui/switch"; import { FrigateConfig } from "@/types/frigateConfig"; import axios from "axios"; import { useEffect, useState } from "react"; import useSWR from "swr"; const NOTIFICATION_SERVICE_WORKER = "notifications-worker.ts"; export default function NotificationView() { const { data: config } = useSWR("config"); // notification key handling const { data: publicKey } = useSWR( config?.notifications?.enabled ? "notifications/pubkey" : null, ); // notification state const [notificationsSubscribed, setNotificationsSubscribed] = useState(); useEffect(() => { navigator.serviceWorker .getRegistration(NOTIFICATION_SERVICE_WORKER) .then((worker) => { setNotificationsSubscribed(worker != null); }); }, []); return ( <>
Notification Settings
{}} />

Enable notifications for Frigate alerts. This requires Frigate to be externally accessible.

{config?.notifications.enabled && (
{ // TODO need to register the worker before enabling the notifications button // TODO make the notifications button show enable / disable depending on current state }
)}
); }