From 218e8ee88847e408719b609e34b4feb840435537 Mon Sep 17 00:00:00 2001 From: prtkjakhar Date: Tue, 17 Oct 2023 14:34:28 +0530 Subject: [PATCH] added incrementaudioused api --- .../src/components/chat-message-item/index.tsx | 2 +- apps/amakrushi/src/context/ContextProvider.tsx | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/amakrushi/src/components/chat-message-item/index.tsx b/apps/amakrushi/src/components/chat-message-item/index.tsx index 01d80c5..e0b556b 100644 --- a/apps/amakrushi/src/components/chat-message-item/index.tsx +++ b/apps/amakrushi/src/components/chat-message-item/index.tsx @@ -163,7 +163,7 @@ const ChatMessageItem: FC = ({ toast.error('No audio'); return; } - context?.playAudio(url); + context?.playAudio(url, content); }; const { content, type } = message; diff --git a/apps/amakrushi/src/context/ContextProvider.tsx b/apps/amakrushi/src/context/ContextProvider.tsx index c6d4b2b..9ffa7b8 100644 --- a/apps/amakrushi/src/context/ContextProvider.tsx +++ b/apps/amakrushi/src/context/ContextProvider.tsx @@ -91,7 +91,7 @@ const ContextProvider: FC<{ }, []); const playAudio = useMemo(() => { - return (url: string) => { + return (url: string, content: any) => { if (!url) { console.error('Audio URL not provided.'); return; @@ -143,6 +143,14 @@ const ContextProvider: FC<{ setAudioElement(null); setAudioPlaying(false); }); + axios + .get( + `${process.env.NEXT_PUBLIC_BASE_URL}/incrementaudioused/${content?.data?.messageId}` + ) + .then((res) => {}) + .catch((err) => { + console.log(err); + }); audio .play() .then(() => { @@ -492,7 +500,7 @@ const ContextProvider: FC<{ clickedAudioUrl, downloadChat, audioPlaying, - setAudioPlaying + setAudioPlaying, }), [ locale, @@ -521,7 +529,7 @@ const ContextProvider: FC<{ clickedAudioUrl, downloadChat, audioPlaying, - setAudioPlaying + setAudioPlaying, ] );