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
|
return Math.random() * (high - low) + low
|
||||||
}
|
}
|
||||||
const idPromise = random(0, 120000000);
|
const idPromise = random(0, 120000000);
|
||||||
this.min.cbMap[idPromise] = promise;
|
this.min.cbMap[idPromise] = {};
|
||||||
return await step.beginDialog('/hear', { id: idPromise, previousResolve: previousResolve });
|
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) {
|
public async talk(step, text: string) {
|
||||||
|
|
|
@ -260,17 +260,16 @@ export class GBVMService extends GBService {
|
||||||
step.activeDialog.state.options = {};
|
step.activeDialog.state.options = {};
|
||||||
step.activeDialog.state.options.cbId = (step.options as any).id;
|
step.activeDialog.state.options.cbId = (step.options as any).id;
|
||||||
step.activeDialog.state.options.previousResolve = (step.options as any).previousResolve;
|
step.activeDialog.state.options.previousResolve = (step.options as any).previousResolve;
|
||||||
|
|
||||||
return await step.prompt('textPrompt', {});
|
return await step.prompt('textPrompt', {});
|
||||||
},
|
},
|
||||||
async step => {
|
async step => {
|
||||||
const cbId = step.activeDialog.state.options.cbId;
|
const cbId = step.activeDialog.state.options.cbId;
|
||||||
const promise = min.cbMap[cbId];
|
const promise = min.cbMap[cbId].promise;
|
||||||
const res = await promise(step, step.result);
|
|
||||||
if (step.activeDialog.state.options.previousResolve != undefined){
|
delete min.cbMap[cbId];
|
||||||
step.activeDialog.state.options.previousResolve();
|
const opts = await promise(step, step.result);
|
||||||
}
|
|
||||||
return await step.next();
|
return await step.replaceDialog ('/hear', opts);
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue