fix routing and checkbox subscribe in chat
Deploy app frontend / app frontend (push) Successful in 1m48s
Deploy app frontend / app frontend (push) Successful in 1m48s
This commit is contained in:
@@ -150,7 +150,7 @@ const stage = ref<'receivePushSubscription' | 'createPushSubscription' | 'remove
|
||||
const { isPending, isError, error, mutate } = useMutation({
|
||||
mutationKey: [stage],
|
||||
mutationFn: async () => {
|
||||
debug({ stage: stage.value })
|
||||
console.log({ stage: stage.value })
|
||||
try {
|
||||
if (stage.value === 'receivePushSubscription') {
|
||||
const chatSettingsDocument = await getUserChatSettingsDocument({
|
||||
@@ -159,13 +159,13 @@ const { isPending, isError, error, mutate } = useMutation({
|
||||
user_chat_role,
|
||||
}).catch((error) => {
|
||||
if (!isNotFoundError(error)) {
|
||||
debug('chatSettingsDocument error', error)
|
||||
console.log('chatSettingsDocument error', error)
|
||||
throw error
|
||||
}
|
||||
debug('chatSettingsDocument not found') // it's ok
|
||||
console.log('chatSettingsDocument not found') // it's ok
|
||||
})
|
||||
if (chatSettingsDocument) {
|
||||
debug(
|
||||
console.log(
|
||||
'chatSettingsDocument.is_push_notification_enabled',
|
||||
chatSettingsDocument.is_push_notification_enabled,
|
||||
)
|
||||
@@ -205,6 +205,7 @@ const { isPending, isError, error, mutate } = useMutation({
|
||||
user_chat_role,
|
||||
is_push_notification_enabled: true,
|
||||
})
|
||||
stage.value = 'removePushSubscription'
|
||||
} else if (stage.value === 'removePushSubscription') {
|
||||
await saveUserChatSettings({
|
||||
qr_code_uri,
|
||||
@@ -226,6 +227,7 @@ const { isPending, isError, error, mutate } = useMutation({
|
||||
watch(
|
||||
[() => stage.value, () => enabled.value],
|
||||
() => {
|
||||
console.log({ stage: stage.value, enabled: enabled.value })
|
||||
if (stage.value === 'removePushSubscription') {
|
||||
if (!enabled.value) mutate()
|
||||
} else if (stage.value === 'createPushSubscription') {
|
||||
|
||||
Reference in New Issue
Block a user