Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d795866

Browse files
committedFeb 2, 2017
Fixed bug with recognizers being called twice.
1 parent 21bf1b3 commit d795866

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed
 

‎Node/core/src/bots/Library.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,10 @@ export class Library extends EventEmitter {
127127
// top intent is passed along as part of routing. The root libraries recognize()
128128
// method will be called a second time so we want to avoid the second recognize
129129
// pass.
130-
var skipRecognize = (context.intent && context.libraryName === this.name);
131-
if (this.recognizers.length > 0 && !skipRecognize) {
130+
if (this.recognizers.length > 0 && context.libraryName !== this.name) {
132131
this.recognizers.recognize(context, callback);
133132
} else {
134-
// Pass through the top intent recognized by the root libraries recognizers.
135-
callback(null, context.intent);
133+
callback(null, context.intent || { intent: 'None', score: 0.0 });
136134
}
137135
}
138136

‎Node/core/src/bots/UniversalBot.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ export class UniversalBot extends Library {
464464
// Run the root libraries recognizers
465465
var context = session.toRecognizeContext();
466466
this.recognize(context, (err, topIntent) => {
467-
if (topIntent && topIntent.score > 0) {
468-
// This intent will be automatically inherited by child libraries
469-
// that don't implement their own recognizers.
470-
context.intent = topIntent;
471-
context.libraryName = this.name;
472-
}
467+
// This intent will be automatically inherited by child libraries
468+
// that don't implement their own recognizers.
469+
// - We're passing along the library name to avoid running our own
470+
// recognizer twice.
471+
context.intent = topIntent;
472+
context.libraryName = this.name;
473473

474474
// Federate across all libraries to find the best route to trigger.
475475
var results = Library.addRouteResult({ score: 0.0, libraryName: this.name });

0 commit comments

Comments
 (0)
Please sign in to comment.