fix routing and checkbox subscribe in chat
Deploy app frontend / app frontend (push) Successful in 1m48s

This commit is contained in:
2024-12-07 20:28:40 +02:00
parent 7d611b6916
commit a420a7a040
4 changed files with 14 additions and 11 deletions
@@ -32,6 +32,7 @@ export const saveUserChatSettings = async ({
const user_uuid = getUserUuid()
const browser_uuid = getBrowserUuid()
const _id = `user_chat_settings:${qr_code_uri}:${chat}:${user_chat_role}:${user_uuid}`
console.log('is_push_notification_enabled', is_push_notification_enabled)
const result = await userChatSettingsDbRemote.upsert(
_id,
(doc): UserChatSettingsDocument | false => {
@@ -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') {
-1
View File
@@ -10,7 +10,6 @@ export const ROUTE_NAMES = {
READ_QR_CODE: 'read-qr-code',
DONATE: 'donate',
PUBLIC_CHAT: 'public-chat',
APP_START: 'app-start',
// CREATE_ACTIONS: 'create-actions',
// MANAGE_SETTINGS: 'manage-settings',
// MANAGE_PROFILE: 'manage-profile',
+7 -6
View File
@@ -9,10 +9,12 @@ const routes = [
{
path: '/',
name: ROUTE_NAMES.HOME,
component: () =>
isRunningStandalone()
? import('@/views/manage/ManageQRCodesView.vue')
: import('@/views/HomeView.vue'),
component: () => import('@/views/HomeView.vue'),
beforeEnter() {
if (isRunningStandalone()) {
return { name: ROUTE_NAMES.MANAGE_DASHBOARD_QR }
}
},
},
{
path: '/create',
@@ -22,8 +24,7 @@ const routes = [
{
path: '/manage',
name: ROUTE_NAMES.MANAGE_DASHBOARD_QR_CODES,
component: () => import('@/views/manage/ManageQRCodesView.vue'),
props: true,
redirect: { name: ROUTE_NAMES.MANAGE_DASHBOARD_QR },
},
{
path: '/manage/qr',