Skip to content
Snippets Groups Projects
Commit 127b343e authored by Greg Fodor's avatar Greg Fodor
Browse files

Handle vapid public get init

parent 2f590138
No related branches found
No related tags found
No related merge requests found
...@@ -500,7 +500,10 @@ document.addEventListener("DOMContentLoaded", async () => { ...@@ -500,7 +500,10 @@ document.addEventListener("DOMContentLoaded", async () => {
retPhxChannel retPhxChannel
.join() .join()
.receive("ok", async data => subscriptions.setVapidPublicKey(data.vapid_public_key)) .receive("ok", async data => subscriptions.setVapidPublicKey(data.vapid_public_key))
.receive("error", res => console.error(res)); .receive("error", res => {
subscriptions.setVapidPublicKey(null);
console.error(res);
});
linkChannel.setSocket(socket); linkChannel.setSocket(socket);
}); });
...@@ -50,6 +50,10 @@ export default class Subscriptions { ...@@ -50,6 +50,10 @@ export default class Subscriptions {
// registration becomes null if failed, non null if registered // registration becomes null if failed, non null if registered
while (this.registration === undefined) await nextTick(); while (this.registration === undefined) await nextTick();
if (!this.registration || !this.registration.pushManager) return null; if (!this.registration || !this.registration.pushManager) return null;
while (this.vapidPublicKey === undefined) await nextTick();
if (this.vapidPublicKey === null) return null;
try { try {
const convertedVapidKey = urlBase64ToUint8Array(this.vapidPublicKey); const convertedVapidKey = urlBase64ToUint8Array(this.vapidPublicKey);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment