From 98ec5e5ee4ff94f9ebbc6600f41c1c890419c4d3 Mon Sep 17 00:00:00 2001 From: Dan Lopez Date: Fri, 19 Jul 2019 10:50:24 -0700 Subject: [PATCH 1/2] update setState() --- package.json | 2 +- src/chat/chat.tsx | 8 +++++--- src/chat/messages/action.tsx | 3 ++- src/chat/messages/buttons.tsx | 3 ++- src/chat/messages/messagetype.tsx | 6 +++--- src/chat/messages/typing-indicator.tsx | 2 +- src/widget/configuration.ts | 4 ++-- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 28bc860..ea12ea3 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "axios": "^0.18.0", "dateformat": "^3.0.3", "laravel-echo": "^1.3.5", - "preact": "^8.1.0", + "preact": "^8.4.2", "preact-compat": "^3.15.0", "preact-render-to-string": "^3.6.0", "preact-router": "^2.5.1", diff --git a/src/chat/chat.tsx b/src/chat/chat.tsx index 352e232..6a6dad3 100644 --- a/src/chat/chat.tsx +++ b/src/chat/chat.tsx @@ -16,8 +16,10 @@ export default class Chat extends Component { this.botman = botman; this.botman.setUserId(this.props.userId); this.botman.setChatServer(this.props.conf.chatServer); - this.state.messages = []; - this.state.replyType = ReplyType.Text; + //this.state.messages = []; + //this.state.replyType = ReplyType.Text; + this.setState({ messages : [] }); + this.setState({ replyType : ReplyType.Text }); } componentDidMount() { @@ -223,4 +225,4 @@ interface IChatState { messages: IMessage[], replyType: string, -} \ No newline at end of file +} diff --git a/src/chat/messages/action.tsx b/src/chat/messages/action.tsx index d9a70c1..c8d2709 100644 --- a/src/chat/messages/action.tsx +++ b/src/chat/messages/action.tsx @@ -26,7 +26,8 @@ export default class Action extends MessageType { performAction(action: IAction) { botman.callAPI(action.value, true, null, (msg: IMessage) => { - this.state.attachmentsVisible = false; + //this.state.attachmentsVisible = false; + this.setState({ attachmentsVisible : false}); this.props.messageHandler({ text: msg.text, type: msg.type, diff --git a/src/chat/messages/buttons.tsx b/src/chat/messages/buttons.tsx index 9f2ad3e..24fc378 100644 --- a/src/chat/messages/buttons.tsx +++ b/src/chat/messages/buttons.tsx @@ -28,7 +28,8 @@ export default class ButtonsType extends MessageType { performAction(button: IButton) { botman.callAPI(button.payload, true, null, (msg: IMessage) => { - this.state.attachmentsVisible = false; + //this.state.attachmentsVisible = false; + this.setState({ attachmentsVisible : false}); this.props.messageHandler({ text: msg.text, type: msg.type, diff --git a/src/chat/messages/messagetype.tsx b/src/chat/messages/messagetype.tsx index a643733..af08173 100644 --- a/src/chat/messages/messagetype.tsx +++ b/src/chat/messages/messagetype.tsx @@ -19,11 +19,11 @@ export default abstract class MessageType extends Component { - this.state.visible = true; - this.state.visibilityChanged = true; + this.setState({ visible : true }); + this.setState({ visibilityChanged : true }); this.onVisibilityChange(); this.props.onVisibilityChange(this.props.message, this.state); }, this.props.timeout || 0); } -} \ No newline at end of file +} diff --git a/src/chat/messages/typing-indicator.tsx b/src/chat/messages/typing-indicator.tsx index 2b621ed..afcb2f9 100644 --- a/src/chat/messages/typing-indicator.tsx +++ b/src/chat/messages/typing-indicator.tsx @@ -13,7 +13,7 @@ export default class TypingIndicator extends MessageType { onVisibilityChange = () => { setTimeout(() => { - this.state.visible = false; + this.setState({ visible : false}); this.props.onVisibilityChange(this.props.message, this.state); }, this.props.message.timeout * 1000); }; diff --git a/src/widget/configuration.ts b/src/widget/configuration.ts index f40d61d..464ef31 100644 --- a/src/widget/configuration.ts +++ b/src/widget/configuration.ts @@ -5,7 +5,7 @@ export const defaultConfiguration: IConfiguration = { frameEndpoint: '/botman/chat', timeFormat: 'HH:MM', dateTimeFormat: 'm/d/yy HH:MM', - title: 'BotMan Widget', + title: 'Experian Help', cookieValidInDays: 1, introMessage: '', placeholderText: 'Send a message...', @@ -22,7 +22,7 @@ export const defaultConfiguration: IConfiguration = { mobileWidth: '300px', videoHeight: 160, aboutLink: 'https://botman.io', - aboutText: '⚡ Powered by BotMan', + aboutText: '⚡ Powered by Botman', chatId: '', userId: '', alwaysUseFloatingButton: false, From bfb2eb49bead1d0e0eefa48dc153326d5317d575 Mon Sep 17 00:00:00 2001 From: Dan Lopez Date: Fri, 19 Jul 2019 10:51:09 -0700 Subject: [PATCH 2/2] update setState() --- src/chat/messages/action.tsx | 1 - src/chat/messages/buttons.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/chat/messages/action.tsx b/src/chat/messages/action.tsx index c8d2709..082bbb4 100644 --- a/src/chat/messages/action.tsx +++ b/src/chat/messages/action.tsx @@ -26,7 +26,6 @@ export default class Action extends MessageType { performAction(action: IAction) { botman.callAPI(action.value, true, null, (msg: IMessage) => { - //this.state.attachmentsVisible = false; this.setState({ attachmentsVisible : false}); this.props.messageHandler({ text: msg.text, diff --git a/src/chat/messages/buttons.tsx b/src/chat/messages/buttons.tsx index 24fc378..07c2033 100644 --- a/src/chat/messages/buttons.tsx +++ b/src/chat/messages/buttons.tsx @@ -28,7 +28,6 @@ export default class ButtonsType extends MessageType { performAction(button: IButton) { botman.callAPI(button.payload, true, null, (msg: IMessage) => { - //this.state.attachmentsVisible = false; this.setState({ attachmentsVisible : false}); this.props.messageHandler({ text: msg.text,