2
0

🚸 Better random IDs generation in setVariable

This commit is contained in:
Baptiste Arnaud
2023-09-26 10:04:28 +02:00
parent 801fea860a
commit a176e23cc8

View File

@@ -5,6 +5,7 @@ import { parseScriptToExecuteClientSideAction } from '../script/executeScript'
import { parseGuessedValueType } from '../../../variables/parseGuessedValueType'
import { parseVariables } from '../../../variables/parseVariables'
import { updateVariablesInSession } from '../../../variables/updateVariablesInSession'
import { createId } from '@paralleldrive/cuid2'
export const executeSetVariable = (
state: SessionState,
@@ -92,13 +93,10 @@ const getExpressionToEvaluate =
return 'new Date(Date.now() - 86400000).toISOString()'
}
case 'Random ID': {
return 'Math.random().toString(36).substring(2, 15)'
return `"${createId()}"`
}
case 'User ID': {
return (
state.typebotsQueue[0].resultId ??
'Math.random().toString(36).substring(2, 15)'
)
return state.typebotsQueue[0].resultId ?? `"${createId()}"`
}
case 'Map item with same index': {
return `const itemIndex = ${options.mapListItemParams?.baseListVariableId}.indexOf(${options.mapListItemParams?.baseItemVariableId})