Skip to content

Commit

Permalink
feat: Pass dialog parameters to isFulfilled function
Browse files Browse the repository at this point in the history
  • Loading branch information
yangeorget committed Aug 27, 2018
1 parent 853d5c9 commit 92eb244
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/botfuel-dialog/src/dialogs/prompt-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class PromptDialog extends Dialog {
// Check if the parameter is already fulfilled with its initial value
// If so, we replace the fulfilled parameter’s entity
// with the first candidate of the same dimension
const replace =
entity.isFulfilled(initialValue, { dialogEntities: {} }) && sameDimCandidates.length >= 1;
const replace = entity.isFulfilled(initialValue, { dialogEntities: {}, dialogParameters: this.parameters })
&& sameDimCandidates.length >= 1;
if (replace) {
const chosenCandidate = sameDimCandidates[0];
candidates = filterIntersectingEntities(candidates, chosenCandidate);
Expand All @@ -85,7 +85,7 @@ class PromptDialog extends Dialog {
}
return candidates.filter(candidate => candidate.dim === entity.dim).reduce(
({ newValue, remainingCandidates }, candidate) => {
if (entity.isFulfilled(newValue, { dialogEntities: {} })) {
if (entity.isFulfilled(newValue, { dialogEntities: {}, dialogParameters: this.parameters })) {
return { newValue, remainingCandidates };
}
return {
Expand Down Expand Up @@ -154,11 +154,13 @@ class PromptDialog extends Dialog {
const priorityB = entityB.priority;
const isFulfilledA = entityA.isFulfilled(matchedEntities[nameA], {
dialogEntities: matchedEntities,
dialogParameters: this.parameters,
})
? 0
: 1;
const isFulfilledB = entityB.isFulfilled(matchedEntities[nameB], {
dialogEntities: matchedEntities,
dialogParameters: this.parameters,
})
? 0
: 1;
Expand Down Expand Up @@ -247,6 +249,7 @@ class PromptDialog extends Dialog {

const isFulfilled = entity.isFulfilled(newValue, {
dialogEntities: matchedEntities,
dialogParameters: this.parameters,
});

// If an entity matching the one we are expecting was found,
Expand Down

0 comments on commit 92eb244

Please sign in to comment.