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

Properly send unsubscribe

parent 46d67677
No related branches found
No related tags found
No related merge requests found
...@@ -54,13 +54,13 @@ export default class Subscriptions { ...@@ -54,13 +54,13 @@ export default class Subscriptions {
const subscriptions = this.getSubscriptionsFromStorage(); const subscriptions = this.getSubscriptionsFromStorage();
if (this.isSubscribed()) { if (this.isSubscribed()) {
const endpoint = subscriptions[this.hubId].endpoint; const subscription = await this.registration.pushManager.getSubscription();
this.hubChannel.unsubscribe(endpoint); this.hubChannel.unsubscribe(subscription);
delete subscriptions[this.hubId]; delete subscriptions[this.hubId];
if (Object.keys(subscriptions).length === 0) { if (Object.keys(subscriptions).length === 0) {
this.registration.pushManager.unregister(endpoint); subscription.unsubscribe();
} }
} else { } else {
let subscription = await this.registration.pushManager.getSubscription(); let subscription = await this.registration.pushManager.getSubscription();
......
...@@ -95,8 +95,8 @@ export default class HubChannel { ...@@ -95,8 +95,8 @@ export default class HubChannel {
this.channel.push("subscribe", { subscription }); this.channel.push("subscribe", { subscription });
}; };
unsubscribe = endpoint => { unsubscribe = subscription => {
this.channel.push("unsubscribe", { endpoint }); this.channel.push("unsubscribe", { subscription });
}; };
sendMessage = body => { sendMessage = body => {
......
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