From a9970f83330f5303d1c4eef94a13b4c17132760d Mon Sep 17 00:00:00 2001 From: Pradipta Ghoshal <50803990+ProCode2@users.noreply.github.com> Date: Fri, 19 Jan 2024 04:11:17 +0530 Subject: [PATCH] fix: stop playing audio when a chat is changed(by stopping audio on unmount) (#171) --- src/components/chatblock.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/chatblock.tsx b/src/components/chatblock.tsx index 30776458..24859adb 100644 --- a/src/components/chatblock.tsx +++ b/src/components/chatblock.tsx @@ -85,7 +85,10 @@ export default function ChatBlock(props: { const interval = setInterval(() => { setPercentagePlayed((audio.currentTime / audio.duration) * 100); }, 10); - return () => clearInterval(interval); + return () => { + stopAudio(); + clearInterval(interval); + }; } }, [audio]);