mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-18 20:26:01 +01:00
Fix error in checkSubscription and improve logging
This commit is contained in:
parent
16b9262bed
commit
3033ad4400
1 changed files with 12 additions and 3 deletions
|
@ -20,10 +20,19 @@ export function checkSubscription(subscription: PushSubscription): void {
|
|||
},
|
||||
contentType: 'application/json'
|
||||
}).then(async response => {
|
||||
const data = await response.json();
|
||||
const data = await response.json;
|
||||
|
||||
if (data.status == 'subscribed') return;
|
||||
if (data.status == 'failed') await unsubscribeServer(subscription);
|
||||
if (data.status == 'subscribed') {
|
||||
console.info('Push subscription is still valid.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.status == 'failed') {
|
||||
console.info('Pushing to this subscription failed too many times, unsubscribing.');
|
||||
await unsubscribeServer(subscription);
|
||||
}
|
||||
|
||||
console.info('Removing push subscription from this browser.');
|
||||
await unsubscribeClient(subscription);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue