Skip to content

Commit

Permalink
added incrementaudioused api
Browse files Browse the repository at this point in the history
  • Loading branch information
prtkjakhar committed Oct 17, 2023
1 parent f7b6a70 commit 218e8ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/amakrushi/src/components/chat-message-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
toast.error('No audio');
return;
}
context?.playAudio(url);
context?.playAudio(url, content);
};

const { content, type } = message;
Expand Down
14 changes: 11 additions & 3 deletions apps/amakrushi/src/context/ContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -492,7 +500,7 @@ const ContextProvider: FC<{
clickedAudioUrl,
downloadChat,
audioPlaying,
setAudioPlaying
setAudioPlaying,
}),
[
locale,
Expand Down Expand Up @@ -521,7 +529,7 @@ const ContextProvider: FC<{
clickedAudioUrl,
downloadChat,
audioPlaying,
setAudioPlaying
setAudioPlaying,
]
);

Expand Down

0 comments on commit 218e8ee

Please sign in to comment.