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