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 user_uuid = getUserUuid()
const browser_uuid = getBrowserUuid() const browser_uuid = getBrowserUuid()
const _id = `user_chat_settings:${qr_code_uri}:${chat}:${user_chat_role}:${user_uuid}` 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( const result = await userChatSettingsDbRemote.upsert(
_id, _id,
(doc): UserChatSettingsDocument | false => { (doc): UserChatSettingsDocument | false => {
@@ -150,7 +150,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 () => {
debug({ stage: stage.value }) console.log({ stage: stage.value })
try { try {
if (stage.value === 'receivePushSubscription') { if (stage.value === 'receivePushSubscription') {
const chatSettingsDocument = await getUserChatSettingsDocument({ const chatSettingsDocument = await getUserChatSettingsDocument({
@@ -159,13 +159,13 @@ const { isPending, isError, error, mutate } = useMutation({
user_chat_role, user_chat_role,
}).catch((error) => { }).catch((error) => {
if (!isNotFoundError(error)) { if (!isNotFoundError(error)) {
debug('chatSettingsDocument error', error) console.log('chatSettingsDocument error', error)
throw error throw error
} }
debug('chatSettingsDocument not found') // it's ok console.log('chatSettingsDocument not found') // it's ok
}) })
if (chatSettingsDocument) { if (chatSettingsDocument) {
debug( console.log(
'chatSettingsDocument.is_push_notification_enabled', 'chatSettingsDocument.is_push_notification_enabled',
chatSettingsDocument.is_push_notification_enabled, chatSettingsDocument.is_push_notification_enabled,
) )
@@ -205,6 +205,7 @@ const { isPending, isError, error, mutate } = useMutation({
user_chat_role, user_chat_role,
is_push_notification_enabled: true, is_push_notification_enabled: true,
}) })
stage.value = 'removePushSubscription'
} else if (stage.value === 'removePushSubscription') { } else if (stage.value === 'removePushSubscription') {
await saveUserChatSettings({ await saveUserChatSettings({
qr_code_uri, qr_code_uri,
@@ -226,6 +227,7 @@ const { isPending, isError, error, mutate } = useMutation({
watch( watch(
[() => stage.value, () => enabled.value], [() => stage.value, () => enabled.value],
() => { () => {
console.log({ stage: stage.value, enabled: enabled.value })
if (stage.value === 'removePushSubscription') { if (stage.value === 'removePushSubscription') {
if (!enabled.value) mutate() if (!enabled.value) mutate()
} else if (stage.value === 'createPushSubscription') { } else if (stage.value === 'createPushSubscription') {
-1
View File
@@ -10,7 +10,6 @@ export const ROUTE_NAMES = {
READ_QR_CODE: 'read-qr-code', READ_QR_CODE: 'read-qr-code',
DONATE: 'donate', DONATE: 'donate',
PUBLIC_CHAT: 'public-chat', PUBLIC_CHAT: 'public-chat',
APP_START: 'app-start',
// CREATE_ACTIONS: 'create-actions', // CREATE_ACTIONS: 'create-actions',
// MANAGE_SETTINGS: 'manage-settings', // MANAGE_SETTINGS: 'manage-settings',
// MANAGE_PROFILE: 'manage-profile', // MANAGE_PROFILE: 'manage-profile',
+7 -6
View File
@@ -9,10 +9,12 @@ const routes = [
{ {
path: '/', path: '/',
name: ROUTE_NAMES.HOME, name: ROUTE_NAMES.HOME,
component: () => component: () => import('@/views/HomeView.vue'),
isRunningStandalone() beforeEnter() {
? import('@/views/manage/ManageQRCodesView.vue') if (isRunningStandalone()) {
: import('@/views/HomeView.vue'), return { name: ROUTE_NAMES.MANAGE_DASHBOARD_QR }
}
},
}, },
{ {
path: '/create', path: '/create',
@@ -22,8 +24,7 @@ const routes = [
{ {
path: '/manage', path: '/manage',
name: ROUTE_NAMES.MANAGE_DASHBOARD_QR_CODES, name: ROUTE_NAMES.MANAGE_DASHBOARD_QR_CODES,
component: () => import('@/views/manage/ManageQRCodesView.vue'), redirect: { name: ROUTE_NAMES.MANAGE_DASHBOARD_QR },
props: true,
}, },
{ {
path: '/manage/qr', path: '/manage/qr',