From 526bd4db1033f3a5cb217bee33752ed123e47db5 Mon Sep 17 00:00:00 2001 From: Raul Garita Ch Date: Wed, 1 Mar 2017 14:16:52 -0600 Subject: [PATCH] Bug Fix: WP not opening direct line channel at initial load (#133) * Bug Fix: WP not opening direct line channel at initial load * Package Version / Readme Updates * Readme fix --- samples/react-bot-framework/README.md | 3 + samples/react-bot-framework/package.json | 2 +- .../components/BotFrameworkChat.tsx | 68 +++++++++++-------- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/samples/react-bot-framework/README.md b/samples/react-bot-framework/README.md index 686e0713c..47c9c4130 100644 --- a/samples/react-bot-framework/README.md +++ b/samples/react-bot-framework/README.md @@ -40,12 +40,15 @@ under the [vs2015-bot-application](./vs2015-bot-application) folder. This is sim Solution|Author(s) --------|--------- bot-framework | Gary Pretty ([@garypretty](http://www.twitter.com/garypretty), [garypretty.co.uk](www.garypretty.co.uk)) +RC0 Update / BugFixing | Raul Garita ([Raul.Garita@buildingi.com](mailto:raul.garita@buildingi.com), [Buildingi](http://www.buildingi.com)) ## Version history Version|Date|Comments -------|----|-------- 1.0|October 11th, 2016|Initial release +1.1|Jan 24th, 2017|Updated to RC0 +1.2|Feb 23rd, 2017|Initial load bug fix ## Disclaimer **THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** diff --git a/samples/react-bot-framework/package.json b/samples/react-bot-framework/package.json index 590bf3787..1fcd7d62c 100644 --- a/samples/react-bot-framework/package.json +++ b/samples/react-bot-framework/package.json @@ -1,6 +1,6 @@ { "name": "sp-bot-chat-webpart", - "version": "0.0.2", + "version": "0.0.3", "private": true, "engines": { "node": ">=0.10.0" diff --git a/samples/react-bot-framework/src/webparts/botFrameworkChat/components/BotFrameworkChat.tsx b/samples/react-bot-framework/src/webparts/botFrameworkChat/components/BotFrameworkChat.tsx index afa7c50cd..998c83df7 100644 --- a/samples/react-bot-framework/src/webparts/botFrameworkChat/components/BotFrameworkChat.tsx +++ b/samples/react-bot-framework/src/webparts/botFrameworkChat/components/BotFrameworkChat.tsx @@ -38,38 +38,13 @@ export default class BotFrameworkChat extends React.Component { - client.clientAuthorizations.add('AuthorizationBotConnector', new Swagger.ApiKeyAuthorization('Authorization', 'BotConnector ' + this.props.directLineSecret, 'header')); - console.log('DirectLine client generated'); - return client; - }).catch((err) => - console.error('Error initializing DirectLine client', err)); - - this.directLineClientSwagger.then((client) => { - client.Conversations.Conversations_NewConversation() - .then((response) => response.obj.conversationId) - .then((conversationId) => { - - this.conversationId = conversationId; - this.pollMessages(client, conversationId); - this.directLineClient = client; - }); - }); - - this.sendAsUserName = this.props.context.pageContext.user.loginName; - - this.printMessage = this.printMessage.bind(this); - } + this.bindDirectLineSecret(); } } @@ -111,6 +86,39 @@ export default class BotFrameworkChat extends React.Component { + client.clientAuthorizations.add('AuthorizationBotConnector', new Swagger.ApiKeyAuthorization('Authorization', 'BotConnector ' + this.props.directLineSecret, 'header')); + console.log('DirectLine client generated'); + return client; + }).catch((err) => + console.error('Error initializing DirectLine client', err)); + + this.directLineClientSwagger.then((client) => { + client.Conversations.Conversations_NewConversation() + .then((response) => response.obj.conversationId) + .then((conversationId) => { + + this.conversationId = conversationId; + this.pollMessages(client, conversationId); + this.directLineClient = client; + }); + }); + + this.sendAsUserName = this.props.context.pageContext.user.loginName; + + this.printMessage = this.printMessage.bind(this); + } + } + protected pollMessages(client, conversationId) { console.log('Starting polling message for conversationId: ' + conversationId); var watermark = null;