Skip to content

Commit

Permalink
fix(basic.gblib): Goto dialog within web.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Sep 18, 2021
1 parent 7c44669 commit 565f200
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions packages/basic.gblib/services/DialogKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,18 +453,22 @@ export class DialogKeywords {
/**
* Prepares the next dialog to be shown to the specified user.
*/
public async gotoDialog(step, fromOrDialogName: string, dialogName: string) {
public async gotoDialog(step, fromOrDialogName: string, dialogName: string) {
if (dialogName) {
let sec = new SecService();
let user = await sec.getUserFromSystemId(fromOrDialogName);
if (!user) {
user = await sec.ensureUser(this.min.instance.instanceId, fromOrDialogName,
fromOrDialogName, null, 'whatsapp', 'from', null);
if (dialogName.charAt(0) === '/') {
await step.beginDialog(fromOrDialogName);
} else {
let sec = new SecService();
let user = await sec.getUserFromSystemId(fromOrDialogName);
if (!user) {
user = await sec.ensureUser(this.min.instance.instanceId, fromOrDialogName,
fromOrDialogName, null, 'whatsapp', 'from', null);
}
await sec.updateUserHearOnDialog(user.userId, dialogName);
}
await sec.updateUserHearOnDialog(user.userId, dialogName);
}
else {
await step.beginDialog(dialogName);
await step.beginDialog(fromOrDialogName);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/basic.gblib/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class GBVMService extends GBService {
});

code = code.replace(/(go to)(\s)(.*)/gi, ($0, $1, $2, $3) => {
return `sys().gotoDialog(step, ${$3})\n`;
return `gotoDialog(step, ${$3})\n`;
});

code = code.replace(/(hear)\s*(\w+)/gi, ($0, $1, $2) => {
Expand Down

0 comments on commit 565f200

Please sign in to comment.