Skip to content

Commit

Permalink
fixed welcome message problem when deactivated
Browse files Browse the repository at this point in the history
  • Loading branch information
dakavisa committed Jan 13, 2020
1 parent a96a7fa commit 2610a12
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dist/articulate-chatbot-widget.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var ArticulateChatbotWidget = function (_Component) {
});

var handler = function handler(response) {
if (response) {
if (response && !response.ignore) {
_this2.addNewBotMessage(response);
}
};
Expand Down Expand Up @@ -240,8 +240,7 @@ var ArticulateChatbotWidget = function (_Component) {
body: JSON.stringify(postPayload)
});
this.setState({
userMessage: '',
botIsTyping: true
userMessage: ''
});
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "articulate-chatbot-widget",
"version": "0.0.6",
"version": "0.0.7",
"description": "Chatbot widget for Articulate based on JiteshGaikwad Chatbot-Widget",
"main": "./lib/index.js",
"scripts": {
Expand Down Expand Up @@ -77,4 +77,4 @@
"react-hot-loader": "^4.12.18",
"video-react": "^0.14.1"
}
}
}
17 changes: 8 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class ArticulateChatbotWidget extends Component {
});

const handler = response => {
if (response) {
if (response && !response.ignore) {
this.addNewBotMessage(response);
}
};
Expand Down Expand Up @@ -141,8 +141,7 @@ export default class ArticulateChatbotWidget extends Component {
body: JSON.stringify(postPayload)
});
this.setState({
userMessage: '',
botIsTyping: true
userMessage: ''
});
}

Expand Down Expand Up @@ -186,7 +185,7 @@ export default class ArticulateChatbotWidget extends Component {
const botAvatarImage = botAvatarURL || botAvatar;
let responses = []

if (response.textResponse){
if (response.textResponse) {
responses.push(
<React.Fragment key={`message_${index}_textResponse`}>
{renderBotAvatar && <img className="botAvatar" src={botAvatarImage} />}
Expand Down Expand Up @@ -216,7 +215,7 @@ export default class ArticulateChatbotWidget extends Component {
);
}

if (response.richResponses && response.richResponses.length > 0){
if (response.richResponses && response.richResponses.length > 0) {
response.richResponses.forEach((richResponse, richResponseIndex) => {
switch (richResponse.type) {
case 'audio':
Expand Down Expand Up @@ -353,7 +352,7 @@ export default class ArticulateChatbotWidget extends Component {
break;
default:
break;
}
}
});
}
return responses;
Expand Down Expand Up @@ -464,11 +463,11 @@ export default class ArticulateChatbotWidget extends Component {
messages.map((message, index) => {
return (
message.bot ?
this.renderBotResponse(message.response, index, index === 0 || !messages[index-1].bot )
this.renderBotResponse(message.response, index, index === 0 || !messages[index - 1].bot)
:
<React.Fragment key={`message_${index}`}>
{index === 0 || messages[index-1].bot ? <img className="userAvatar" src={userAvatarImage} /> : null}
<p className={`userMsg ${(index > 0 && !messages[index-1].bot) && 'userMessageWithoutAvatar'}`}>{message.message}</p>
{index === 0 || messages[index - 1].bot ? <img className="userAvatar" src={userAvatarImage} /> : null}
<p className={`userMsg ${(index > 0 && !messages[index - 1].bot) && 'userMessageWithoutAvatar'}`}>{message.message}</p>
<div className="clearfix" />
</React.Fragment>
)
Expand Down

0 comments on commit 2610a12

Please sign in to comment.