Rename _this and update package.json

This commit is contained in:
Jorge Ramos 2018-05-12 22:36:12 -03:00
parent b122882aac
commit af7db2246d
6 changed files with 6164 additions and 33 deletions

View file

@ -75,15 +75,15 @@ export class ConsoleDirectLine extends GBService {
});
// TODO: Remove *this* issue.
let _this = this;
let _this_ = this;
directLineClient.then(function (client) {
client.Conversations.Conversations_StartConversation()
.then(function (response) {
return response.obj.conversationId;
})
})
.then(function (conversationId) {
_this.sendMessagesFromConsole(client, conversationId);
_this.pollMessages(client, conversationId);
_this_.sendMessagesFromConsole(client, conversationId);
_this_.pollMessages(client, conversationId);
})
.catch(function (err) {
console.error('Error starting conversation', err);
@ -92,8 +92,9 @@ export class ConsoleDirectLine extends GBService {
}
sendMessagesFromConsole(client, conversationId) {
let _this = this;
var stdin = process.openStdin();
let _this_ = this;
process.stdin.resume();
var stdin = process.stdin;
process.stdout.write('Command> ');
stdin.addListener('data', function (e) {
var input = e.toString().trim();
@ -111,8 +112,8 @@ export class ConsoleDirectLine extends GBService {
text: input,
type: 'message',
from: {
id: _this.directLineClientName,
name: _this.directLineClientName
id: _this_.directLineClientName,
name: _this_.directLineClientName
}
}
}).catch(function (err) {
@ -126,7 +127,7 @@ export class ConsoleDirectLine extends GBService {
/** TBD: Poll Messages from conversation using DirectLine client */
pollMessages(client, conversationId) {
let _this = this;
let _this_ = this;
console.log('Starting polling message for conversationId: ' + conversationId);
var watermark = null;
setInterval(function () {
@ -135,7 +136,7 @@ export class ConsoleDirectLine extends GBService {
watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages
return response.obj.activities;
})
.then(_this.printMessages, _this.directLineClientName);
.then(_this_.printMessages, _this_.directLineClientName);
}, this.pollInterval);
}
@ -193,6 +194,6 @@ export class ConsoleDirectLine extends GBService {
console.log('*'.repeat(width + 1) + '/');
}
}

View file

@ -63,7 +63,7 @@ export class GBImporter {
localPath: string,
cb: GBServiceCallback<IGBInstance>
) {
let _this = this;
let _this_ = this;
let packageJson = JSON.parse(
Fs.readFileSync(UrlJoin(localPath, "package.json"), "utf8")

View file

@ -90,7 +90,7 @@ export class GBMinService {
buildMin(cb: GBServiceCallback<GBMinInstance>, server: any, appPackages: Array<IGBPackage>) {
var _this = this;
var _this_ = this;
// Serves default UI on root address '/'.
@ -102,7 +102,7 @@ export class GBMinService {
// Loads all bot instances from storage.
_this.core.loadInstances((instances: IGBInstance[], err) => {
_this_.core.loadInstances((instances: IGBInstance[], err) => {
// Gets the authorization key for each instance from Bot Service.
@ -127,7 +127,7 @@ export class GBMinService {
// Returns the instance object to clients requesting bot info.
let botId = req.params.botId;
_this.core.loadInstance(
_this_.core.loadInstance(
botId,
(instance: IGBInstance, err) => {
if (instance) {
@ -154,9 +154,9 @@ export class GBMinService {
let min = new GBMinInstance();
min.botId = instance.botId;
min.core = _this.core;
min.conversationalService = _this.conversationalService;
_this.core.loadInstance(min.botId, (data, err) => {
min.core = _this_.core;
min.conversationalService = _this_.conversationalService;
_this_.core.loadInstance(min.botId, (data, err) => {
min.instance = data;
@ -309,7 +309,7 @@ export class GBMinService {
return new Promise((resolve, reject) => {
try {
var _this = this;
var _this_ = this;
let totalPackages = 0;
let additionalPath = GBConfigService.get("ADDITIONAL_DEPLOY_PATH");
let paths = [this.deployFolder];
@ -387,7 +387,7 @@ export class GBMinService {
botPackages.forEach(e => {
logger.trace(`Deploying bot: ${e}...`);
_this.deployer.deployBot(e, (data, err) => {
_this_.deployer.deployBot(e, (data, err) => {
logger.trace(`Bot: ${e} deployed...`);
});
});

View file

@ -109,7 +109,7 @@ class GBUIApp extends React.Component {
}
setupBotConnection(secret) {
let _this = this;
let _this_ = this;
window["botchatDebug"] = true;
const botConnection = new DirectLine({
@ -125,7 +125,7 @@ class GBUIApp extends React.Component {
name: "startGB"
});
_this.setState({ botConnection: botConnection });
_this_.setState({ botConnection: botConnection });
}
});
@ -138,22 +138,22 @@ class GBUIApp extends React.Component {
activity.type === "event" && activity.name === "loadInstance"
)
.subscribe(activity => {
_this.setState({ instance: activity.value });
_this_.setState({ instance: activity.value });
});
botConnection.activity$
.filter(activity => activity.type === "event" && activity.name === "stop")
.subscribe(activity => {
if (_this.player) {
_this.player.stop();
if (_this_.player) {
_this_.player.stop();
}
});
botConnection.activity$
.filter(activity => activity.type === "event" && activity.name === "play")
.subscribe(activity => {
_this.setState({ playerType: activity.value.playerType });
_this.player.play(activity.value.data);
_this_.setState({ playerType: activity.value.playerType });
_this_.player.play(activity.value.data);
});
}

View file

@ -123,7 +123,7 @@ export class KBService {
// Performs search.
var _this = this;
var _this_ = this;
if (instance.searchKey) {
let service = new AzureSearch(
@ -138,7 +138,7 @@ export class KBService {
// Ponders over configuration.
if (results[0]["@search.score"] >= searchScore) {
_this.getAnswerById(
_this_.getAnswerById(
instance.instanceId,
results[0].answerId,
(answer, err) => {
@ -476,9 +476,9 @@ export class KBService {
UrlJoin(localPath, "subjects.json"),
instance
);
let _this = this;
let _this_ = this;
setTimeout(() => {
_this.importKbTabularDirectory(
_this_.importKbTabularDirectory(
localPath,
instance,
packageStorage.packageId
@ -491,12 +491,12 @@ export class KBService {
instance: IGBInstance,
packageId: number
) {
let _this = this;
let _this_ = this;
Walk.files(
UrlJoin(localPath, "tabular"),
(basedir, filename, stat, next) => {
if (filename.endsWith(".tsv")) {
_this.importKbTabularFile(
_this_.importKbTabularFile(
basedir,
filename,
instance.instanceId,

6130
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff