mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-20 07:49:57 +00:00
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
|
@ -1,6 +1,4 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PushSubscriptionError } from '~/composables/push-notifications/types'
|
|
||||||
|
|
||||||
defineProps<{ show?: boolean }>()
|
defineProps<{ show?: boolean }>()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -36,5 +36,11 @@ const { modelValue } = defineModel<{
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
</head>
|
</head>
|
||||||
<p>{{ message }}</p>
|
<p>{{ message }}</p>
|
||||||
|
<p py-2>
|
||||||
|
<NuxtLink font-bold text-primary href="https://github.com/elk-zone/elk" target="_blank" flex="~ row" items-center gap-x-2>
|
||||||
|
{{ $t('settings.notifications.push_notifications.subscription_error.repo_link') }}
|
||||||
|
<span inline-block aria-hidden="true" i-ri:external-link-line class="rtl-flip" />
|
||||||
|
</NuxtLink>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -46,9 +46,9 @@ export const createPushSubscription = async (
|
||||||
if (error.code === 11 && error.name === 'InvalidStateError')
|
if (error.code === 11 && error.name === 'InvalidStateError')
|
||||||
useError = new PushSubscriptionError('too_many_registrations', 'Too many registrations')
|
useError = new PushSubscriptionError('too_many_registrations', 'Too many registrations')
|
||||||
else if (error.code === 20 && error.name === 'AbortError')
|
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')
|
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()
|
return getRegistration()
|
||||||
.then(getPushSubscription)
|
.then(getPushSubscription)
|
||||||
|
|
|
@ -25,7 +25,8 @@ export interface CustomEmojisInfo {
|
||||||
emojis: mastodon.v1.CustomEmoji[]
|
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 {
|
export class PushSubscriptionError extends Error {
|
||||||
code: PushSubscriptionErrorCode
|
code: PushSubscriptionErrorCode
|
||||||
constructor(code: PushSubscriptionErrorCode, message?: string) {
|
constructor(code: PushSubscriptionErrorCode, message?: string) {
|
||||||
|
|
|
@ -370,10 +370,13 @@
|
||||||
"save_settings": "Save settings",
|
"save_settings": "Save settings",
|
||||||
"subscription_error": {
|
"subscription_error": {
|
||||||
"clear_error": "Clear error",
|
"clear_error": "Clear error",
|
||||||
|
"invalid_vapid_key": "The VAPID public key seems to be invalid.",
|
||||||
"permission_denied": "Permission denied: enable notifications in your browser.",
|
"permission_denied": "Permission denied: enable notifications in your browser.",
|
||||||
|
"repo_link": "Elk's repository in Github",
|
||||||
"request_error": "An error occurred while requesting the subscription, try again and if the error persists, please report the issue to the Elk repository.",
|
"request_error": "An error occurred while requesting the subscription, try again and if the error persists, please report the issue to the Elk repository.",
|
||||||
"title": "Could not subscribe to push notifications",
|
"title": "Could not subscribe to push notifications",
|
||||||
"too_many_registrations": "Due to browser limitations, Elk cannot use the push notifications service for multiple accounts on different servers. You should unsubscribe from push notifications on another account and try again."
|
"too_many_registrations": "Due to browser limitations, Elk cannot use the push notifications service for multiple accounts on different servers. You should unsubscribe from push notifications on another account and try again.",
|
||||||
|
"vapid_not_supported": "Your browser supports Web Push Notifications, but does not seem to implement the VAPID protocol."
|
||||||
},
|
},
|
||||||
"title": "Push notifications settings",
|
"title": "Push notifications settings",
|
||||||
"undo_settings": "Undo changes",
|
"undo_settings": "Undo changes",
|
||||||
|
|
|
@ -370,10 +370,13 @@
|
||||||
"save_settings": "Guardar cambios",
|
"save_settings": "Guardar cambios",
|
||||||
"subscription_error": {
|
"subscription_error": {
|
||||||
"clear_error": "Limpiar error",
|
"clear_error": "Limpiar error",
|
||||||
|
"invalid_vapid_key": "La clave pública VAPID parece no ser válida.",
|
||||||
"permission_denied": "Permiso denegado: habilita las notificaciones en tu navegador.",
|
"permission_denied": "Permiso denegado: habilita las notificaciones en tu navegador.",
|
||||||
|
"repo_link": "Repositorio de Elk en Github",
|
||||||
"request_error": "Se produjo un error al solicitar la suscripción, inténtalo de nuevo y si el error persiste, notifica la incidencia en el repositorio de Elk.",
|
"request_error": "Se produjo un error al solicitar la suscripción, inténtalo de nuevo y si el error persiste, notifica la incidencia en el repositorio de Elk.",
|
||||||
"title": "No se pudo suscribir a las notificaciones push",
|
"title": "No se pudo suscribir a las notificaciones push",
|
||||||
"too_many_registrations": "Debido a las limitaciones del navegador, Elk no puede habilitar las notificaciones push para múltiples cuentas en diferentes servidores. Deberá cancelar las subscripciones a notificaciones push en las otras cuentas e intentarlo de nuevo."
|
"too_many_registrations": "Debido a las limitaciones del navegador, Elk no puede habilitar las notificaciones push para múltiples cuentas en diferentes servidores. Deberá cancelar las subscripciones a notificaciones push en las otras cuentas e intentarlo de nuevo.",
|
||||||
|
"vapid_not_supported": "Su navegador es compatible con las notificaciones web push, pero no parece implementar el protocolo VAPID."
|
||||||
},
|
},
|
||||||
"title": "Ajustes de notificaciones push",
|
"title": "Ajustes de notificaciones push",
|
||||||
"undo_settings": "Deshacer cambios",
|
"undo_settings": "Deshacer cambios",
|
||||||
|
|
Loading…
Reference in a new issue