2
0

(embedBubble) Enable variable embed height

This commit is contained in:
Baptiste Arnaud
2023-02-19 09:53:57 +01:00
parent d22cc45a97
commit 621cd58244
14 changed files with 226 additions and 198 deletions

View File

@ -1,5 +1,7 @@
import { deepParseVariable } from '@/features/variables'
import {
BubbleBlock,
BubbleBlockType,
ChatReply,
Group,
InputBlock,
@ -38,7 +40,7 @@ export const executeGroup =
if (isBubbleBlock(block)) {
messages.push(
deepParseVariable(newSessionState.typebot.variables)(block)
parseBubbleBlock(newSessionState.typebot.variables)(block)
)
lastBubbleBlockId = block.id
continue
@ -126,3 +128,25 @@ const getPrefilledInputValue =
)?.value ?? undefined
)
}
const parseBubbleBlock =
(variables: SessionState['typebot']['variables']) =>
(block: BubbleBlock): ChatReply['messages'][0] => {
switch (block.type) {
case BubbleBlockType.EMBED: {
const message = deepParseVariable(variables)(block)
return {
...message,
content: {
...message.content,
height:
typeof message.content.height === 'string'
? parseFloat(message.content.height)
: message.content.height,
},
}
}
default:
return deepParseVariable(variables)(block)
}
}