Skip to content

Commit

Permalink
Merge pull request #118 from ML-Leonardo/button-click-issue
Browse files Browse the repository at this point in the history
Added button click user message to list
  • Loading branch information
JWandrocke authored and GitHub Enterprise committed Aug 27, 2021
2 parents 4684938 + dcc9076 commit 43b5364
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/Input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { safeArrayOfItem } from 'helpers'
import Menu from 'components/Menu'
import MenuSVG from 'components/svgs/menu'
import './style.scss'
import { pathOr } from 'ramda'

// Number of minimum char to display the char limit.
const NUMBER_BEFORE_LIMIT = 5
Expand Down Expand Up @@ -106,7 +107,8 @@ class Input extends Component {
}
sendMenuSelection = (action) => {
if (action) {
this.props.onSubmit(action)
const title = pathOr(null, ['content', 'title'], action)
this.props.onSubmit(action, title)
}
}
sendMessage = () => {
Expand All @@ -115,7 +117,7 @@ class Input extends Component {
this.props.onSubmit({
type: 'text',
content,
})
}, content.title)
this.setState(prevState => {
const historyValues = append(content, prevState.historyValues)
const previousValues = append('', historyValues)
Expand Down
4 changes: 3 additions & 1 deletion src/components/Message/QuickReplies.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { truncate, safeArrayOfItem, validButtonContent } from 'helpers'

import Text from './Text'
import { PrevArrow, NextArrow } from 'components/arrows'
import { pathOr } from 'ramda'

class QuickReplies extends Component {
state = {
Expand Down Expand Up @@ -46,8 +47,9 @@ class QuickReplies extends Component {
// then one button click has already been send.
if (!this._messageHasAlreadyBeenSent) {
this._messageHasAlreadyBeenSent = true
const title = pathOr(null, ['content', 'title'], message)
this.setState({ displayQuickReplies: false }, () => {
this.props.sendMessage(message)
this.props.sendMessage(message, title)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Chat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class Chat extends Component {
}

this.setState(
prevState => ({ messages: concat(prevState.messages, [backendMessage]) }),
prevState => ({ messages: concat(prevState.messages, [userMessage || backendMessage]) }),
() => {
if (sendMessagePromise) {
addUserMessage(userMessage || backendMessage)
Expand Down

0 comments on commit 43b5364

Please sign in to comment.