2
0

🐛 (settings) Fix typing emulation not working

Closes #330
This commit is contained in:
Baptiste Arnaud
2023-02-23 07:42:45 +01:00
parent 31711dc24d
commit 889e6a4f7e
4 changed files with 13 additions and 6 deletions

View File

@ -12,7 +12,7 @@ import { useEffect, useState } from 'react'
import { sendRequest } from 'utils'
import { PackageIcon } from './icons'
const intervalDuration = 1000 * 60 // 30 seconds
const intervalDuration = 1000 * 60
export const NewVersionPopup = () => {
const { typebot, save } = useTypebot()

View File

@ -68,6 +68,7 @@ export const ChatChunk = (props: Props) => {
{(message) => (
<HostBubble
message={message}
typingEmulation={props.settings.typingEmulation}
onTransitionEnd={displayNextMessage}
/>
)}

View File

@ -9,6 +9,7 @@ import type {
EmbedBubbleContent,
ImageBubbleContent,
TextBubbleContent,
TypingEmulation,
VideoBubbleContent,
} from 'models'
import { BubbleBlockType } from 'models/features/blocks/bubbles/enums'
@ -16,6 +17,7 @@ import { Match, Switch } from 'solid-js'
type Props = {
message: ChatMessage
typingEmulation: TypingEmulation
onTransitionEnd: () => void
}
@ -29,6 +31,7 @@ export const HostBubble = (props: Props) => {
<Match when={props.message.type === BubbleBlockType.TEXT}>
<TextBubble
content={props.message.content as Omit<TextBubbleContent, 'richText'>}
typingEmulation={props.typingEmulation}
onTransitionEnd={onTransitionEnd}
/>
</Match>

View File

@ -5,8 +5,8 @@ import { computeTypingDuration } from '../utils/computeTypingDuration'
type Props = {
content: Pick<TextBubbleContent, 'html' | 'plainText'>
typingEmulation: TypingEmulation
onTransitionEnd: () => void
typingEmulation?: TypingEmulation
}
export const showAnimationDuration = 400
@ -29,10 +29,13 @@ export const TextBubble = (props: Props) => {
onMount(() => {
if (!isTyping) return
const typingDuration = computeTypingDuration(
props.content.plainText,
props.typingEmulation ?? defaultTypingEmulation
)
const typingDuration =
props.typingEmulation?.enabled === false
? 0
: computeTypingDuration(
props.content.plainText,
props.typingEmulation ?? defaultTypingEmulation
)
setTimeout(() => {
onTypingEnd()
}, typingDuration)