Merge branch 'debug-webpush' into 'master'

Better error handler for push notifications subscription

See merge request framasoft/mobilizon!952
This commit is contained in:
Thomas Citharel 2021-06-24 09:49:34 +00:00
commit 9ff66dc356
4 changed files with 18 additions and 11 deletions

View file

@ -1053,5 +1053,6 @@
"An error has occured while refreshing the page.": "An error has occured while refreshing the page.", "An error has occured while refreshing the page.": "An error has occured while refreshing the page.",
"Join group {group}": "Join group {group}", "Join group {group}": "Join group {group}",
"Public preview": "Public preview", "Public preview": "Public preview",
"On {instance} and other federated instances": "On {instance} and other federated instances" "On {instance} and other federated instances": "On {instance} and other federated instances",
"Error while subscribing to push notifications": "Error while subscribing to push notifications"
} }

View file

@ -45,7 +45,7 @@
"Accessible through link": "Accessible uniquement par lien", "Accessible through link": "Accessible uniquement par lien",
"Account": "Compte", "Account": "Compte",
"Actions": "Actions", "Actions": "Actions",
"Activate browser notification": "Activer le notifications du navigateur", "Activate browser notification": "Activer les notifications du navigateur",
"Activated": "Activé", "Activated": "Activé",
"Active": "Actif·ive", "Active": "Actif·ive",
"Activity": "Activité", "Activity": "Activité",
@ -1144,5 +1144,6 @@
"An error has occured while refreshing the page.": "Une erreur est survenue lors du rafraîchissement de la page.", "An error has occured while refreshing the page.": "Une erreur est survenue lors du rafraîchissement de la page.",
"Join group {group}": "Rejoindre le groupe {group}", "Join group {group}": "Rejoindre le groupe {group}",
"Public preview": "Aperçu public", "Public preview": "Aperçu public",
"On {instance} and other federated instances": "Sur {instance} et d'autres instances fédérées" "On {instance} and other federated instances": "Sur {instance} et d'autres instances fédérées",
"Error while subscribing to push notifications": "Erreur lors de la souscriptions aux notifications push"
} }

View file

@ -33,14 +33,15 @@ export async function subscribeUserToPush(): Promise<PushSubscription | null> {
data?.config?.webPush?.publicKey data?.config?.webPush?.publicKey
), ),
}; };
try {
const pushSubscription = await registration.pushManager.subscribe( const pushSubscription = await registration.pushManager.subscribe(
subscribeOptions subscribeOptions
); );
console.log( console.debug("Received PushSubscription: ", pushSubscription);
"Received PushSubscription: ",
JSON.stringify(pushSubscription)
);
return pushSubscription; return pushSubscription;
} catch (e) {
console.error("Error while subscribing to push notifications", e);
}
} }
return null; return null;
} }

View file

@ -597,6 +597,10 @@ export default class Notifications extends Vue {
}); });
this.subscribed = true; this.subscribed = true;
console.log(data); console.log(data);
} else {
this.$notifier.error(
this.$t("Error while subscribing to push notifications") as string
);
} }
} else { } else {
console.log("can't do webpush"); console.log("can't do webpush");