2
0

🦴 Add settings page backbone

This commit is contained in:
Baptiste Arnaud
2021-12-23 13:49:24 +01:00
parent 4d8056dfe8
commit 79aede1f3f
14 changed files with 238 additions and 12 deletions

View File

@ -1,6 +1,8 @@
import React, { useEffect, useRef, useState } from 'react'
import { useHostAvatars } from '../../../../contexts/HostAvatarsContext'
import { useTypebot } from '../../../../contexts/TypebotContext'
import { StepType, TextStep } from '../../../../models'
import { computeTypingTimeout } from '../../../../services/chat'
import { TypingContent } from './TypingContent'
type HostMessageBubbleProps = {
@ -16,15 +18,18 @@ export const HostMessageBubble = ({
step,
onTransitionEnd,
}: HostMessageBubbleProps) => {
const { typebot } = useTypebot()
const { typingEmulation } = typebot.settings
const { updateLastAvatarOffset } = useHostAvatars()
const messageContainer = useRef<HTMLDivElement | null>(null)
const [isTyping, setIsTyping] = useState(true)
useEffect(() => {
const wordCount = step.content.plainText.match(/(\w+)/g)?.length ?? 0
const typedWordsPerMinute = 250
const typingTimeout = (wordCount / typedWordsPerMinute) * 60000
sendAvatarOffset()
const typingTimeout = computeTypingTimeout(
step.content.plainText,
typingEmulation
)
setTimeout(() => {
onTypingEnd()
}, typingTimeout)