Debug Notification API failures

This commit is contained in:
Noah Petherbridge 2024-08-12 20:41:04 -07:00
parent 2be90b4a81
commit a8dda91c3c

View File

@ -1562,6 +1562,16 @@ window.addEventListener("DOMContentLoaded", (event) => {
$pushEnableButton = document.querySelector("#grant-push-permission"), $pushEnableButton = document.querySelector("#grant-push-permission"),
$pushDeniedHelp = document.querySelector("#push-denied-help"); $pushDeniedHelp = document.querySelector("#push-denied-help");
// Is the Notification API unavailable?
if (typeof(window.Notification) === "undefined") {
$pushStatusDefault.innerHTML = `<i class="fa fa-xmark mr-1"></i> Notification API unavailable`;
$pushStatusDefault.style.display = "";
return;
}
// And testing widely for errors...
try {
// Get the current permission status: default, granted, denied. // Get the current permission status: default, granted, denied.
const showPermission = (permission) => { const showPermission = (permission) => {
$pushStatusGranted.style.display = "none"; $pushStatusGranted.style.display = "none";
@ -1604,6 +1614,10 @@ window.addEventListener("DOMContentLoaded", (event) => {
} }
}); });
}); });
} catch(err) {
$pushStatusDefault.innerHTML = `<i class="fa fa-xmark mr-1"></i> Error: ${err}`;
$pushStatusDefault.style.display = "block";
}
}); });
// Location tab scripts. // Location tab scripts.