Skip to content

Commit

Permalink
fix(basic.gblib): Fix BASIC options set by SET instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Apr 30, 2021
1 parent 53a5d8d commit 80697cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 10 additions & 4 deletions packages/basic.gblib/services/DialogKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,20 @@ export class DialogKeywords {
* Reference to the base system keywords functions to be called.
*/
public internalSys: SystemKeywords;

private user;

/**
* Current user object to get BASIC properties read.
*/
public user;

/**
* When creating this keyword facade, a bot instance is
* specified among the deployer service.
*/
constructor(min: GBMinInstance, deployer: GBDeployer, step: GBDialogStep, user) {
this.min = min;
this.internalSys = new SystemKeywords(min, deployer, user);
this.user = user;
this.internalSys = new SystemKeywords(min, deployer, this);
}

/**
Expand Down Expand Up @@ -163,6 +166,7 @@ export class DialogKeywords {
user.systemUser = await sec.updateUserLocale(user.systemUser.userId, language);

await this.min.userProfile.set(step.context, user);
this.user = user;
}

/**
Expand All @@ -175,8 +179,9 @@ export class DialogKeywords {
const user = await this.min.userProfile.get(step.context, {});
user.basicOptions.maxLines = count;
await this.min.userProfile.set(step.context, user);
this.user = user;
}

/**
* Defines translator behaviour.
*
Expand All @@ -187,6 +192,7 @@ export class DialogKeywords {
const user = await this.min.userProfile.get(step.context, {});
user.basicOptions.translatorOn = (on.trim() === "on");
await this.min.userProfile.set(step.context, user);
this.user = user;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions packages/basic.gblib/services/SystemKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import urlJoin = require('url-join');
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
import { SecService } from '../../security.gbapp/services/SecService';
import { DialogKeywords } from './DialogKeywords';
const request = require('request-promise-native');
const path = require('path');
const sgMail = require('@sendgrid/mail');
Expand All @@ -59,17 +60,18 @@ export class SystemKeywords {
* Reference to the deployer service.
*/
private readonly deployer: GBDeployer;

dk: DialogKeywords;

private user;

/**
* When creating this keyword facade, a bot instance is
* specified among the deployer service.
*/
constructor(min: GBMinInstance, deployer: GBDeployer, user) {
this.user = user;
constructor(min: GBMinInstance, deployer: GBDeployer, dk: DialogKeywords) {
this.min = min;
this.deployer = deployer;
this.dk = dk;
}

/**
Expand Down Expand Up @@ -290,9 +292,9 @@ export class SystemKeywords {


let maxLines = 100;
if (this.user.basicOptions && this.user.basicOptions.maxLines) {
if (this.user.basicOptions.maxLines.toString().toLowerCase() !== "default") {
maxLines = Number.parseInt(this.user.basicOptions.maxLines).valueOf();
if (this.dk.user.basicOptions && this.dk.user.basicOptions.maxLines) {
if (this.dk.user.basicOptions.maxLines.toString().toLowerCase() !== "default") {
maxLines = Number.parseInt(this.dk.user.basicOptions.maxLines).valueOf();
}
}

Expand Down

0 comments on commit 80697cf

Please sign in to comment.