Skip to content

Commit

Permalink
🐛 Fix empty placeholder ignored
Browse files Browse the repository at this point in the history
Closes #1660
  • Loading branch information
baptisteArno committed Jul 22, 2024
1 parent ec2a53f commit 0237c6f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 27 deletions.
4 changes: 1 addition & 3 deletions packages/bot-engine/blocks/inputs/date/parseDateInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ export const parseDateInput =
return {
...block,
options: {
...deepParseVariables(variables, { removeEmptyStrings: true })(
block.options
),
...deepParseVariables(variables)(block.options),
min: parseDateLimit(
block.options.min,
block.options.hasTime,
Expand Down
10 changes: 3 additions & 7 deletions packages/bot-engine/executeGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ export const parseInput =
}
case InputBlockType.NUMBER: {
const parsedBlock = deepParseVariables(
state.typebotsQueue[0].typebot.variables,
{ removeEmptyStrings: true }
state.typebotsQueue[0].typebot.variables
)({
...block,
prefilledValue: getPrefilledInputValue(
Expand Down Expand Up @@ -327,8 +326,7 @@ export const parseInput =
}
case InputBlockType.RATING: {
const parsedBlock = deepParseVariables(
state.typebotsQueue[0].typebot.variables,
{ removeEmptyStrings: true }
state.typebotsQueue[0].typebot.variables
)({
...block,
prefilledValue: getPrefilledInputValue(
Expand All @@ -346,9 +344,7 @@ export const parseInput =
}
}
default: {
return deepParseVariables(state.typebotsQueue[0].typebot.variables, {
removeEmptyStrings: true,
})({
return deepParseVariables(state.typebotsQueue[0].typebot.variables)({
...block,
runtimeOptions: await computeRuntimeOptions(state)(block),
prefilledValue: getPrefilledInputValue(
Expand Down
10 changes: 3 additions & 7 deletions packages/bot-engine/parseBubbleBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ export const parseBubbleBlock = (
}

case BubbleBlockType.EMBED: {
const message = deepParseVariables(variables, {
removeEmptyStrings: true,
})(block)
const message = deepParseVariables(variables)(block)
return {
...message,
content: {
Expand All @@ -82,9 +80,7 @@ export const parseBubbleBlock = (
}
case BubbleBlockType.VIDEO: {
const parsedContent = block.content
? deepParseVariables(variables, { removeEmptyStrings: true })(
block.content
)
? deepParseVariables(variables)(block.content)
: undefined

return {
Expand All @@ -100,7 +96,7 @@ export const parseBubbleBlock = (
}
}
default:
return deepParseVariables(variables, { removeEmptyStrings: true })(block)
return deepParseVariables(variables)(block)
}
}

Expand Down
15 changes: 5 additions & 10 deletions packages/bot-engine/startSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ export const startSession = async ({
typebot: {
id: typebot.id,
settings: deepParseVariables(
initialState.typebotsQueue[0].typebot.variables,
{ removeEmptyStrings: true }
initialState.typebotsQueue[0].typebot.variables
)(typebot.settings),
theme: sanitizeAndParseTheme(typebot.theme, {
variables: initialState.typebotsQueue[0].typebot.variables,
Expand Down Expand Up @@ -274,8 +273,7 @@ export const startSession = async ({
typebot: {
id: typebot.id,
settings: deepParseVariables(
newSessionState.typebotsQueue[0].typebot.variables,
{ removeEmptyStrings: true }
newSessionState.typebotsQueue[0].typebot.variables
)(typebot.settings),
theme: sanitizeAndParseTheme(typebot.theme, {
variables: initialState.typebotsQueue[0].typebot.variables,
Expand All @@ -293,8 +291,7 @@ export const startSession = async ({
typebot: {
id: typebot.id,
settings: deepParseVariables(
newSessionState.typebotsQueue[0].typebot.variables,
{ removeEmptyStrings: true }
newSessionState.typebotsQueue[0].typebot.variables
)(typebot.settings),
theme: sanitizeAndParseTheme(typebot.theme, {
variables: initialState.typebotsQueue[0].typebot.variables,
Expand Down Expand Up @@ -472,11 +469,9 @@ const sanitizeAndParseTheme = (
{ variables }: { variables: Variable[] }
): Theme => ({
general: theme.general
? deepParseVariables(variables, { removeEmptyStrings: true })(theme.general)
: undefined,
chat: theme.chat
? deepParseVariables(variables, { removeEmptyStrings: true })(theme.chat)
? deepParseVariables(variables)(theme.general)
: undefined,
chat: theme.chat ? deepParseVariables(variables)(theme.chat) : undefined,
customCss: theme.customCss
? removeLiteBadgeCss(parseVariables(variables)(theme.customCss))
: undefined,
Expand Down

0 comments on commit 0237c6f

Please sign in to comment.