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 { sendRequest } from 'utils'
import { PackageIcon } from './icons' import { PackageIcon } from './icons'
const intervalDuration = 1000 * 60 // 30 seconds const intervalDuration = 1000 * 60
export const NewVersionPopup = () => { export const NewVersionPopup = () => {
const { typebot, save } = useTypebot() const { typebot, save } = useTypebot()

View File

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

View File

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

View File

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