From 7aca3f2768387b000156edbc84ae36693325eb09 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherepennikov Date: Mon, 2 Sep 2019 18:34:05 +0300 Subject: [PATCH] Add IConfiguration.oneTimeButtons option --- src/chat/messages/action.tsx | 4 +++- src/chat/messages/buttons.tsx | 4 +++- src/typings/index.ts | 10 ++++++---- src/widget/configuration.ts | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/chat/messages/action.tsx b/src/chat/messages/action.tsx index 082bbb4..8634d62 100644 --- a/src/chat/messages/action.tsx +++ b/src/chat/messages/action.tsx @@ -26,7 +26,9 @@ export default class Action extends MessageType { performAction(action: IAction) { botman.callAPI(action.value, true, null, (msg: IMessage) => { - this.setState({ attachmentsVisible : false}); + if (this.props.conf.oneTimeButtons) { + 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 07c2033..5580c53 100644 --- a/src/chat/messages/buttons.tsx +++ b/src/chat/messages/buttons.tsx @@ -28,7 +28,9 @@ export default class ButtonsType extends MessageType { performAction(button: IButton) { botman.callAPI(button.payload, true, null, (msg: IMessage) => { - this.setState({ attachmentsVisible : false}); + if (this.props.conf.oneTimeButtons) { + this.setState({attachmentsVisible: false}); + } this.props.messageHandler({ text: msg.text, type: msg.type, diff --git a/src/typings/index.ts b/src/typings/index.ts index 2755a44..005c872 100644 --- a/src/typings/index.ts +++ b/src/typings/index.ts @@ -1,5 +1,3 @@ - - export interface IMessageTypeProps { message: IMessage, calculatedTimeout?: number, @@ -45,7 +43,7 @@ export interface IAttachment { } export interface IElement { - title : string, + title: string, image_url: string, item_url: string, subtitle: string, @@ -106,6 +104,10 @@ export interface IConfiguration { */ sendWidgetOpenedEvent: boolean, widgetOpenedEventData: string, + /* + * Hide buttons after action fired + */ + oneTimeButtons: boolean, mainColor: string, headerTextColor: string, bubbleBackground: string, @@ -133,4 +135,4 @@ export interface IConfiguration { echoEventName: string, init?: Function -} \ No newline at end of file +} diff --git a/src/widget/configuration.ts b/src/widget/configuration.ts index 464ef31..c8bba5b 100644 --- a/src/widget/configuration.ts +++ b/src/widget/configuration.ts @@ -12,6 +12,7 @@ export const defaultConfiguration: IConfiguration = { displayMessageTime: true, sendWidgetOpenedEvent: false, widgetOpenedEventData: '', + oneTimeButtons: true, mainColor: '#408591', headerTextColor: '#333', bubbleBackground: '#408591',