@@ -99,6 +99,7 @@ async function requestNotificationPermission() {
|
||||
const subscription = await registration.pushManager
|
||||
.subscribe(await subscribeOptionsPromise)
|
||||
.catch(async (error) => {
|
||||
console.debug('subscribe error', error)
|
||||
const oldSubscription = await registration.pushManager.getSubscription()
|
||||
if (!oldSubscription) {
|
||||
throw error
|
||||
@@ -150,7 +151,7 @@ const stage = ref<'receivePushSubscription' | 'createPushSubscription' | 'remove
|
||||
const { isPending, isError, error, mutate } = useMutation({
|
||||
mutationKey: [stage],
|
||||
mutationFn: async () => {
|
||||
console.debug(stage.value)
|
||||
console.debug('stage', stage.value)
|
||||
try {
|
||||
if (stage.value === 'receivePushSubscription') {
|
||||
const chatSettingsDocument = await getUserChatSettingsDocument({
|
||||
@@ -158,8 +159,15 @@ const { isPending, isError, error, mutate } = useMutation({
|
||||
chat,
|
||||
user_chat_role,
|
||||
}).catch((error) => {
|
||||
if (!isNotFoundError(error)) throw error
|
||||
if (!isNotFoundError(error)) {
|
||||
console.debug('chatSettingsDocument error not found - its ok', error)
|
||||
throw error
|
||||
}
|
||||
console.debug('chatSettingsDocument error', error)
|
||||
})
|
||||
if (chatSettingsDocument) {
|
||||
console.debug('chatSettingsDocument', chatSettingsDocument)
|
||||
}
|
||||
if (
|
||||
(chatSettingsDocument && chatSettingsDocument.is_push_notification_enabled) ||
|
||||
(!chatSettingsDocument &&
|
||||
@@ -203,6 +211,7 @@ const { isPending, isError, error, mutate } = useMutation({
|
||||
}
|
||||
} catch (error) {
|
||||
enabled.value = false
|
||||
console.debug('unknown error at stage ', stage.value, error)
|
||||
throw error
|
||||
}
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user