Skip to content

Commit

Permalink
fix(whatsapp.gblib): Multi-turn dialog fixed in BASIC processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Aug 30, 2019
1 parent 47df1f1 commit 4689bfb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
12 changes: 10 additions & 2 deletions packages/core.gbapp/services/GBAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,16 @@ export class DialogClass {
return Math.random() * (high - low) + low
}
const idPromise = random(0, 120000000);
this.min.cbMap[idPromise] = promise;
return await step.beginDialog('/hear', { id: idPromise, previousResolve: previousResolve });
this.min.cbMap[idPromise] = {};
this.min.cbMap[idPromise].promise = promise;

const opts = { id: idPromise, previousResolve: previousResolve };
if (previousResolve !== undefined) {
previousResolve(opts);
}
else{
await step.beginDialog('/hear', opts);
}
}

public async talk(step, text: string) {
Expand Down
13 changes: 6 additions & 7 deletions packages/core.gbapp/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,16 @@ export class GBVMService extends GBService {
step.activeDialog.state.options = {};
step.activeDialog.state.options.cbId = (step.options as any).id;
step.activeDialog.state.options.previousResolve = (step.options as any).previousResolve;

return await step.prompt('textPrompt', {});
},
async step => {
const cbId = step.activeDialog.state.options.cbId;
const promise = min.cbMap[cbId];
const res = await promise(step, step.result);
if (step.activeDialog.state.options.previousResolve != undefined){
step.activeDialog.state.options.previousResolve();
}
return await step.next();
const promise = min.cbMap[cbId].promise;

delete min.cbMap[cbId];
const opts = await promise(step, step.result);

return await step.replaceDialog ('/hear', opts);
}
])
);
Expand Down

0 comments on commit 4689bfb

Please sign in to comment.