Don't show webpush section if navigator.serviceWorker is undefined

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-06-29 14:46:28 +02:00
parent 78ec74d253
commit ea01b50b32
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -686,7 +686,7 @@ export default class Notifications extends Vue {
} }
async checkCanShowWebPush(): Promise<boolean> { async checkCanShowWebPush(): Promise<boolean> {
if (!window.isSecureContext && !("serviceWorker" in navigator)) if (!window.isSecureContext || !("serviceWorker" in navigator))
return Promise.resolve(false); return Promise.resolve(false);
const registration = await navigator.serviceWorker.getRegistration(); const registration = await navigator.serviceWorker.getRegistration();
return registration !== undefined; return registration !== undefined;