🐛 (bot) Fix double callback on video and audio bubble
This commit is contained in:
@@ -25,17 +25,19 @@ export const AudioBubble = (props: Props) => {
|
||||
props.onTransitionEnd(ref?.offsetTop)
|
||||
}
|
||||
|
||||
const onCanPlay = () => {
|
||||
clearTimeout(typingTimeout)
|
||||
setIsTyping(false)
|
||||
setTimeout(autoPlay, showAnimationDuration)
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
typingTimeout = setTimeout(() => {
|
||||
if (audioElement) audioElement.removeEventListener('canplay', onCanPlay)
|
||||
setIsTyping(false)
|
||||
setTimeout(autoPlay, showAnimationDuration)
|
||||
}, defaultTypingDuration)
|
||||
if (audioElement)
|
||||
audioElement.oncanplay = () => {
|
||||
clearTimeout(typingTimeout)
|
||||
setIsTyping(false)
|
||||
setTimeout(autoPlay, showAnimationDuration)
|
||||
}
|
||||
if (audioElement) audioElement.addEventListener('canplay', onCanPlay)
|
||||
})
|
||||
|
||||
onCleanup(() => {
|
||||
|
||||
@@ -27,21 +27,23 @@ export const VideoBubble = (props: Props) => {
|
||||
props.onTransitionEnd(ref?.offsetTop)
|
||||
}
|
||||
|
||||
const onCanPlay = () => {
|
||||
clearTimeout(typingTimeout)
|
||||
setIsTyping(false)
|
||||
setTimeout(autoPlay, showAnimationDuration)
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
console.log(videoElement)
|
||||
typingTimeout = setTimeout(
|
||||
() => {
|
||||
if (videoElement) videoElement.removeEventListener('canplay', onCanPlay)
|
||||
setIsTyping(false)
|
||||
setTimeout(autoPlay, showAnimationDuration)
|
||||
},
|
||||
videoElement ? defaultTypingDuration : 2000
|
||||
)
|
||||
if (videoElement)
|
||||
videoElement.oncanplay = () => {
|
||||
clearTimeout(typingTimeout)
|
||||
setIsTyping(false)
|
||||
setTimeout(autoPlay, showAnimationDuration)
|
||||
}
|
||||
if (videoElement) videoElement.addEventListener('canplay', onCanPlay)
|
||||
})
|
||||
|
||||
onCleanup(() => {
|
||||
|
||||
Reference in New Issue
Block a user