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