fix(whatsapp.gblib): Multi-turn dialog fixed in BASIC processing.
This commit is contained in:
parent
47df1f154a
commit
4689bfb238
2 changed files with 16 additions and 9 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
])
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue