fix(engine): 🐛 Embed bubble variable
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { EmbedBubbleStep } from 'models'
|
import { EmbedBubbleStep } from 'models'
|
||||||
import { TypingContent } from './TypingContent'
|
import { TypingContent } from './TypingContent'
|
||||||
|
import { parseVariables } from 'services/variable'
|
||||||
|
import { useTypebot } from 'contexts/TypebotContext'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
step: EmbedBubbleStep
|
step: EmbedBubbleStep
|
||||||
@@ -10,9 +12,15 @@ type Props = {
|
|||||||
export const showAnimationDuration = 400
|
export const showAnimationDuration = 400
|
||||||
|
|
||||||
export const EmbedBubble = ({ step, onTransitionEnd }: Props) => {
|
export const EmbedBubble = ({ step, onTransitionEnd }: Props) => {
|
||||||
|
const { typebot } = useTypebot()
|
||||||
const messageContainer = useRef<HTMLDivElement | null>(null)
|
const messageContainer = useRef<HTMLDivElement | null>(null)
|
||||||
const [isTyping, setIsTyping] = useState(true)
|
const [isTyping, setIsTyping] = useState(true)
|
||||||
|
|
||||||
|
const url = useMemo(
|
||||||
|
() => parseVariables(typebot.variables)(step.content?.url),
|
||||||
|
[step.content?.url, typebot.variables]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
showContentAfterMediaLoad()
|
showContentAfterMediaLoad()
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -51,7 +59,7 @@ export const EmbedBubble = ({ step, onTransitionEnd }: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
<iframe
|
<iframe
|
||||||
id="embed-bubble-content"
|
id="embed-bubble-content"
|
||||||
src={step.content.url}
|
src={url}
|
||||||
className={
|
className={
|
||||||
'w-full z-20 p-4 content-opacity ' +
|
'w-full z-20 p-4 content-opacity ' +
|
||||||
(isTyping ? 'opacity-0' : 'opacity-100')
|
(isTyping ? 'opacity-0' : 'opacity-100')
|
||||||
|
|||||||
Reference in New Issue
Block a user