feat(pwa): add more errors and elk repo link in push notifications subscription errors (#1610)
This commit is contained in:
parent
2cf8f591e8
commit
0cc4c41315
6 changed files with 18 additions and 7 deletions
|
@ -46,9 +46,9 @@ export const createPushSubscription = async (
|
|||
if (error.code === 11 && error.name === 'InvalidStateError')
|
||||
useError = new PushSubscriptionError('too_many_registrations', 'Too many registrations')
|
||||
else if (error.code === 20 && error.name === 'AbortError')
|
||||
console.error('Your browser supports Web Push Notifications, but does not seem to implement the VAPID protocol.')
|
||||
useError = new PushSubscriptionError('vapid_not_supported', 'Your browser supports Web Push Notifications, but does not seem to implement the VAPID protocol.')
|
||||
else if (error.code === 5 && error.name === 'InvalidCharacterError')
|
||||
console.error('The VAPID public key seems to be invalid:', vapidKey)
|
||||
useError = new PushSubscriptionError('invalid_vapid_key', `The VAPID public key seems to be invalid: ${vapidKey}`)
|
||||
|
||||
return getRegistration()
|
||||
.then(getPushSubscription)
|
||||
|
|
|
@ -25,7 +25,8 @@ export interface CustomEmojisInfo {
|
|||
emojis: mastodon.v1.CustomEmoji[]
|
||||
}
|
||||
|
||||
export type PushSubscriptionErrorCode = 'too_many_registrations'
|
||||
export type PushSubscriptionErrorCode = 'too_many_registrations' | 'vapid_not_supported' | 'invalid_vapid_key'
|
||||
|
||||
export class PushSubscriptionError extends Error {
|
||||
code: PushSubscriptionErrorCode
|
||||
constructor(code: PushSubscriptionErrorCode, message?: string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue