Skip to content

Commit

Permalink
⏪ Revert onCanPlay callback
Browse files Browse the repository at this point in the history
Introduced too many issues in prod
  • Loading branch information
baptisteArno committed Jul 12, 2023
1 parent 0b4b15c commit d6c6434
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 49 deletions.
2 changes: 1 addition & 1 deletion packages/embeds/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.0.78",
"version": "0.0.79",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ type Props = {
}

const showAnimationDuration = 400
const defaultTypingDuration = 5000
let isPlayed = false
const typingDuration = 500

let typingTimeout: NodeJS.Timeout

Expand All @@ -18,29 +17,18 @@ export const AudioBubble = (props: Props) => {
let audioElement: HTMLAudioElement | undefined
const [isTyping, setIsTyping] = createSignal(true)

const autoPlay = async () => {
if (isPlayed) return
isPlayed = true
try {
if (audioElement) await audioElement.play()
} catch (e) {
console.warn('Could not autoplay the audio:', e)
}

props.onTransitionEnd(ref?.offsetTop)
}

onMount(() => {
if (audioElement)
audioElement.oncanplay = () => {
clearTimeout(typingTimeout)
setIsTyping(false)
setTimeout(autoPlay, showAnimationDuration)
}
typingTimeout = setTimeout(() => {
setIsTyping(false)
setTimeout(autoPlay, showAnimationDuration)
}, defaultTypingDuration)
setTimeout(() => {
const audioElement = ref?.querySelector('audio')
if (audioElement)
audioElement
.play()
.catch((e) => console.warn('Could not autoplay the audio:', e))
props.onTransitionEnd(ref?.offsetTop)
}, showAnimationDuration)
}, typingDuration)
})

onCleanup(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,28 @@ type Props = {
}

export const showAnimationDuration = 400
const defaultTypingDuration = 5000
let isPlayed = false

let typingTimeout: NodeJS.Timeout

export const VideoBubble = (props: Props) => {
let ref: HTMLDivElement | undefined
let videoElement: HTMLVideoElement | undefined
const [isTyping, setIsTyping] = createSignal(true)

const autoPlay = async () => {
if (isPlayed) return
isPlayed = true
try {
if (videoElement) await videoElement.play()
} catch (e) {
console.warn('Could not autoplay the video:', e)
}
props.onTransitionEnd(ref?.offsetTop)
const onTypingEnd = () => {
const videoElement = ref?.querySelector('video')
if (videoElement)
videoElement
.play()
.catch((e) => console.warn('Could not autoplay the video:', e))
if (!isTyping()) return
setIsTyping(false)
setTimeout(() => {
props.onTransitionEnd(ref?.offsetTop)
}, showAnimationDuration)
}

onMount(() => {
if (videoElement)
videoElement.oncanplay = () => {
clearTimeout(typingTimeout)
setIsTyping(false)
setTimeout(autoPlay, showAnimationDuration)
}
typingTimeout = setTimeout(
() => {
setIsTyping(false)
setTimeout(autoPlay, showAnimationDuration)
},
videoElement ? defaultTypingDuration : 2000
)
typingTimeout = setTimeout(onTypingEnd, 2000)
})

onCleanup(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.0.78",
"version": "0.0.79",
"description": "React library to display typebots on your website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

2 comments on commit d6c6434

@vercel
Copy link

@vercel vercel bot commented on d6c6434 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

rhino.cr8.ai
sheep.cr8.ai
snake.cr8.ai
svhm.mprs.in
tiger.cr8.ai
video.cr8.ai
yoda.riku.ai
zebra.cr8.ai
alvodelas.com
bemestar.club
bergamo.store
bot.krdfy.com
brainplay.fun
cat.hidden.sg
cgcassets.com
cnvhub.com.br
facelabko.com
filmylogy.com
goldorayo.com
rabbit.cr8.ai
shop.mexwa.my
signup.cr8.ai
start.taxt.co
turkey.cr8.ai
vhpage.cr8.ai
vitamyway.com
am.nigerias.io
an.nigerias.io
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.mail2wa.me
bot.rslabs.pro
bots.bng.tools
bots.bridge.ai
chad.gocto.com
chat.hayuri.id
chat.uprize.hu
chatgpt.lam.ee
chicken.cr8.ai
drayumi.social
gollum.riku.ai
gsbulletin.com
journey.cr8.ai
panther.cr7.ai
panther.cr8.ai
pay.sifuim.com
penguin.cr8.ai
stan.vselise.com
typebot.aloe.bot
voicehelp.cr8.ai
zap.fundviser.in
link.venturasuceder.com
mainmenu.diddancing.com
manualhandlingcourse.ie
mdb.baleia.progenbr.com
mdb.equipe.progenbr.com
mdb.evento.progenbr.com
prebook.enthrallart.com
primitive-shapes.cr8.ai
register.kandabrand.com
sell.sellitwithgary.com
signup.hypemarketing.in
sistemacanadense.online
subfooter.wpwakanda.com
survey.hypemarketing.in
testbot.afterorigin.com
tigerfull.amzooline.com
typebot.influencer.love
www.chatgpt-biliran.com
91181264.your-access.one
abg-assistent.m-vogel.de
ai.chromebookstoreph.com
bot.ativandograna.online
chat.ambassadorelena.com
chat.hiabhaykulkarni.com
concept.socialcliques.me
contextone.wpwakanda.com
form.sergiolimajr.com.br
hunterbot.saleshunter.ai
invite.bridesquadapp.com
link.cascadigital.com.br
login.algorithmpress.com
mail2wa.barrettamario.it
onboarding.growthside.io
reward.onlinebotdemo.xyz
stap.venturemarketing.in
type.opaulovieira.com.br
aibot.angrybranding.co.uk
app.photosbackupin1.click
bot.aidigitalmarketing.kr
bot.amicidisanfaustino.it
bot.arraesecenteno.com.br
bot.blackboxsports.com.br
bot.cabinrentalagency.com
bot.fusionstarreviews.com
bot.ristorantekintsugi.it
boyfriend-breakup.riku.ai
brigadeirosemdrama.com.br
budget.pizzeriaforno89.it

@vercel
Copy link

@vercel vercel bot commented on d6c6434 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

Please sign in to comment.