Merge branch 'fix-push-notifications-safari' into 'master'

Fix Notifications page broken page on Safari

Closes #772

See merge request framasoft/mobilizon!991
This commit is contained in:
Thomas Citharel 2021-07-21 10:55:45 +00:00
commit 9b6aee0102
2 changed files with 2 additions and 2 deletions

View File

@ -50,7 +50,7 @@ export async function unsubscribeUserToPush(): Promise<string | undefined> {
console.log("performing unsubscribeUserToPush");
const registration = await navigator.serviceWorker.ready;
console.log("found registration", registration);
const subscription = await registration.pushManager.getSubscription();
const subscription = await registration.pushManager?.getSubscription();
console.log("found subscription", subscription);
if (subscription && (await subscription?.unsubscribe()) === true) {
console.log("done unsubscription");

View File

@ -715,7 +715,7 @@ export default class Notifications extends Vue {
private async isSubscribed(): Promise<boolean> {
if (!("serviceWorker" in navigator)) return Promise.resolve(false);
const registration = await navigator.serviceWorker.getRegistration();
return (await registration?.pushManager.getSubscription()) != null;
return (await registration?.pushManager?.getSubscription()) != null;
}
private async deleteFeedToken(token: string): Promise<void> {