Ensure notifications register button is only disabled when both all cameras and every individual camera is disabled

This commit is contained in:
Josh Hawkins 2025-05-16 06:53:58 -05:00
parent 8c9e8a26c4
commit a47da11b10

View File

@ -165,23 +165,23 @@ export default function NotificationView({
const [registration, setRegistration] = const [registration, setRegistration] =
useState<ServiceWorkerRegistration | null>(); useState<ServiceWorkerRegistration | null>();
useEffect(() => { // useEffect(() => {
if (!("Notification" in window) || !window.isSecureContext) { // if (!("Notification" in window) || !window.isSecureContext) {
return; // return;
} // }
navigator.serviceWorker // navigator.serviceWorker
.getRegistration(NOTIFICATION_SERVICE_WORKER) // .getRegistration(NOTIFICATION_SERVICE_WORKER)
.then((worker) => { // .then((worker) => {
if (worker) { // if (worker) {
setRegistration(worker); // setRegistration(worker);
} else { // } else {
setRegistration(null); // setRegistration(null);
} // }
}) // })
.catch(() => { // .catch(() => {
setRegistration(null); // setRegistration(null);
}); // });
}, []); // }, []);
// form // form
@ -520,7 +520,9 @@ export default function NotificationView({
<Button <Button
aria-label={t("notification.registerDevice")} aria-label={t("notification.registerDevice")}
disabled={ disabled={
!config?.notifications.enabled || publicKey == undefined (!config?.notifications.enabled &&
notificationCameras.length === 0) ||
publicKey == undefined
} }
onClick={() => { onClick={() => {
if (registration == null) { if (registration == null) {