l-min-components 1.7.1419 → 1.7.1420

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.7.1419",
3
+ "version": "1.7.1420",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -2,7 +2,7 @@ import styled from "styled-components";
2
2
  import EarIcon from "../icons/ears";
3
3
  import SpeakerIcon from "../icons/speaker";
4
4
  import classNames from "classnames";
5
- import { useState } from "react";
5
+ import { useEffect, useState } from "react";
6
6
  import { useSpeechSynthesis } from "react-speech-kit";
7
7
  import useAudioPlayer from "../../../useAudioPlayer";
8
8
  import AudioWaveComponent from "../../../useAudioPlayer/audioWave";
@@ -15,7 +15,7 @@ const PlayButton = ({ type, refernceText, audio }) => {
15
15
  },
16
16
  });
17
17
 
18
- const { play, isPlaying, isReady } = useAudioPlayer({
18
+ const { play, isPlaying, isReady, stop } = useAudioPlayer({
19
19
  streamSrc: audio?.url,
20
20
  src: audio?.uploaded_media_url,
21
21
  });
@@ -24,6 +24,15 @@ const PlayButton = ({ type, refernceText, audio }) => {
24
24
 
25
25
  const disabled = type !== "ai" && !isReady;
26
26
 
27
+ useEffect(() => {
28
+ return () => {
29
+ if (showWave) {
30
+ cancel();
31
+ stop();
32
+ }
33
+ };
34
+ }, [showWave]);
35
+
27
36
  return (
28
37
  <Container
29
38
  disabled={disabled}
@@ -1,4 +1,4 @@
1
- import React, { useContext } from "react";
1
+ import React, { useEffect } from "react";
2
2
 
3
3
  import { FaPause } from "react-icons/fa";
4
4
  import {
@@ -25,6 +25,14 @@ const ResponseAudio = ({ url, streamUrl }) => {
25
25
  streamSrc: streamUrl,
26
26
  });
27
27
 
28
+ useEffect(() => {
29
+ return () => {
30
+ if (isPlaying) {
31
+ stop();
32
+ }
33
+ };
34
+ }, [isPlaying]);
35
+
28
36
  return (
29
37
  <ResponseAudioContainer
30
38
  className={classNames({