3737<script setup lang="ts">
3838import type { CSSProperties } from ' vue' ;
3939import { defineProps , watch , ref } from ' vue' ;
40+ import PubSub from ' pubsub-js' ;
4041
4142import type { NotificationCardProps } from ' ../types' ;
4243import { generateElapsedTimeText } from ' ../utils/commonUtils' ;
44+ import { eventTypes , events } from ' ../utils/constants' ;
4345import CloseIcon from ' ./CloseIcon.vue' ;
4446import TimerIcon from ' ./TimerIcon.vue' ;
47+ import useSiren from ' ../composables/useSiren' ;
4548import defaultAvatarDark from ' ../assets/dark/defaultAvatarDark.png' ;
4649import defaultAvatarLight from ' ../assets/light/defaultAvatarLight.png' ;
4750
4851import ' ../styles/card.css' ;
49- import useSiren from ' ../composables/useSiren' ;
5052
5153const props = defineProps <NotificationCardProps >();
5254
@@ -60,14 +62,19 @@ let cardContainerStyle: CSSProperties;
6062
6163const defaultAvatar: string = props ?.darkMode ? defaultAvatarDark : defaultAvatarLight ;
6264
63- const handleDelete = (event : MouseEvent | KeyboardEvent ) => {
64- deleteAnimation .value = ' siren-sdk-delete-animation' ;
65+ const handleDelete = async (event : MouseEvent | KeyboardEvent ): Promise <void > => {
66+ event .stopPropagation ();
67+ const isSuccess = await props .deleteById (props .notification .id , false );
68+
69+ if (isSuccess ) {
70+ deleteAnimation .value = ' siren-sdk-delete-animation' ;
6571
6672 setTimeout (() => {
67- props .deleteById (props .notification .id );
68- }, 200 );
73+ const payload = { id: props .notification .id , action: eventTypes .DELETE_ITEM };
6974
70- event .stopPropagation ();
75+ PubSub .publish (events .NOTIFICATION_LIST_EVENT , JSON .stringify (payload ));
76+ }, 200 );
77+ }
7178};
7279
7380const handleNotificationCardClick = () => {
0 commit comments