Skip to content

Commit

Permalink
fix(basic-skills): reused choice will not start with fresh variables (#…
Browse files Browse the repository at this point in the history
…11949)

* fix(basic-skills): reused choice will not start with fresh variables

* remove unecessary action

Co-authored-by: Laurent Leclerc-Poulin <laurentleclercpoulin@gmail.com>
  • Loading branch information
davidvitora and laurentlp committed Jul 20, 2022
1 parent 1f01d7f commit 93b3fc0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/basic-skills/src/backend/choice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const generateFlow = async (
): Promise<sdk.FlowGenerationResult> => {
const { variableName } = data.config
const randomId = variableName && variableName.length ? variableName : data.randomId
const keySuffix = randomId ? `-${randomId}` : ''

const hardRetryLimit = 10
const nbMaxRetries = Math.min(Number(data.config.nbMaxRetries), hardRetryLimit)
Expand Down Expand Up @@ -87,6 +88,10 @@ const generateFlow = async (
{
name: 'entry',
onEnter: [
{
type: sdk.NodeActionType.RunAction,
name: `builtin/setVariable {"type":"temp","name":"skill-choice-invalid-count${keySuffix}","value": 0 }`
},
{
type: sdk.NodeActionType.RenderElement,
name: `#!${data.contentId}`,
Expand Down
13 changes: 13 additions & 0 deletions modules/basic-skills/src/backend/choice_legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const generateFlowLegacy = async (data: ChoiceData): Promise<sdk.FlowGenerationR
const hardRetryLimit = 10
const nbMaxRetries = Math.min(Number(data.config.nbMaxRetries), hardRetryLimit)
const repeatQuestion = yn(data.config.repeatChoicesOnInvalid)
const keySuffix = randomId ? `-${randomId}` : ''

const sorrySteps = []

Expand All @@ -32,6 +33,18 @@ const generateFlowLegacy = async (data: ChoiceData): Promise<sdk.FlowGenerationR
{
name: 'entry',
onEnter: [
{
type: sdk.NodeActionType.RunAction,
name: `builtin/setVariable {"type":"temp","name":"skill-choice-invalid-count${keySuffix}","value": 0}`
},
{
type: sdk.NodeActionType.RunAction,
name: `builtin/setVariable {"type":"temp","name":"skill-choice-valid${keySuffix}","value": null}`
},
{
type: sdk.NodeActionType.RunAction,
name: `builtin/setVariable {"type":"temp","name":"skill-choice-ret${keySuffix}","value": null}`
},
{
type: sdk.NodeActionType.RenderElement,
name: `#!${data.contentId}`,
Expand Down

0 comments on commit 93b3fc0

Please sign in to comment.