1
0
forked from test/crm

fix: capture notification mark as read event

This commit is contained in:
Shariq Ansari 2024-08-16 19:54:47 +05:30
parent 53a352358b
commit 7c434db5d8

View File

@ -18,10 +18,7 @@
<div class="flex gap-1"> <div class="flex gap-1">
<Tooltip :text="__('Mark all as read')"> <Tooltip :text="__('Mark all as read')">
<div> <div>
<Button <Button variant="ghost" @click="() => markAllAsRead()">
variant="ghost"
@click="() => notificationsStore().mark_as_read.reload()"
>
<template #icon> <template #icon>
<MarkAsDoneIcon class="h-4 w-4" /> <MarkAsDoneIcon class="h-4 w-4" />
</template> </template>
@ -48,7 +45,7 @@
:key="n.comment" :key="n.comment"
:to="getRoute(n)" :to="getRoute(n)"
class="flex cursor-pointer items-start gap-2.5 px-4 py-2.5 hover:bg-gray-100" class="flex cursor-pointer items-start gap-2.5 px-4 py-2.5 hover:bg-gray-100"
@click="mark_as_read(n.comment || n.notification_type_doc)" @click="markAsRead(n.comment || n.notification_type_doc)"
> >
<div class="mt-1 flex items-center gap-2.5"> <div class="mt-1 flex items-center gap-2.5">
<div <div
@ -98,6 +95,7 @@ import { notificationsStore } from '@/stores/notifications'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { timeAgo } from '@/utils' import { timeAgo } from '@/utils'
import { onClickOutside } from '@vueuse/core' import { onClickOutside } from '@vueuse/core'
import { capture } from '@/telemetry'
import { Tooltip } from 'frappe-ui' import { Tooltip } from 'frappe-ui'
import { ref, onMounted, onBeforeUnmount } from 'vue' import { ref, onMounted, onBeforeUnmount } from 'vue'
@ -113,17 +111,23 @@ onClickOutside(
}, },
{ {
ignore: ['#notifications-btn'], ignore: ['#notifications-btn'],
} },
) )
function toggleNotificationPanel() { function toggleNotificationPanel() {
notificationsStore().toggle() notificationsStore().toggle()
} }
function mark_as_read(doc) { function markAsRead(doc) {
capture('notification_mark_as_read')
notificationsStore().mark_doc_as_read(doc) notificationsStore().mark_doc_as_read(doc)
} }
function markAllAsRead() {
capture('notification_mark_all_as_read')
notificationsStore().mark_as_read.reload()
}
onBeforeUnmount(() => { onBeforeUnmount(() => {
$socket.off('crm_notification') $socket.off('crm_notification')
}) })