forked from potsda.mn/mobilizon
Merge branch 'handle-service-worker-registration-firefox-privacy' into 'master'
Handle service worker registration with Firefox « forget all site data » Closes #819 See merge request framasoft/mobilizon!1022
This commit is contained in:
commit
9ec91c8796
|
@ -686,10 +686,15 @@ export default class Notifications extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkCanShowWebPush(): Promise<boolean> {
|
async checkCanShowWebPush(): Promise<boolean> {
|
||||||
|
try {
|
||||||
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;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return Promise.resolve(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async created(): Promise<void> {
|
async created(): Promise<void> {
|
||||||
|
@ -713,9 +718,14 @@ export default class Notifications extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async isSubscribed(): Promise<boolean> {
|
private async isSubscribed(): Promise<boolean> {
|
||||||
|
try {
|
||||||
if (!("serviceWorker" in navigator)) return Promise.resolve(false);
|
if (!("serviceWorker" in navigator)) return Promise.resolve(false);
|
||||||
const registration = await navigator.serviceWorker.getRegistration();
|
const registration = await navigator.serviceWorker.getRegistration();
|
||||||
return (await registration?.pushManager?.getSubscription()) != null;
|
return (await registration?.pushManager?.getSubscription()) != null;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return Promise.resolve(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deleteFeedToken(token: string): Promise<void> {
|
private async deleteFeedToken(token: string): Promise<void> {
|
||||||
|
|
Loading…
Reference in a new issue