Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

Commit

Permalink
allow emitting messages with no arguments closes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJordens committed Mar 2, 2018
1 parent 422bbf9 commit 9c4bec1
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/app/js/components/column/messageSender/MessageSenderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class MessageSender extends Component {
this.getSuggestionValue = this.getSuggestionValue.bind(this)
this.addMessageArgument = this.addMessageArgument.bind(this)
this.removeMessageArgument = this.removeMessageArgument.bind(this)
this.noMessageArgument = this.noMessageArgument.bind(this)
}

componentWillReceiveProps(nextProps) {
Expand Down Expand Up @@ -99,7 +100,7 @@ class MessageSender extends Component {
if ( !this.state.tab.connected )
return

if ( this.state.eventName && this.state.messageCollection.length )
if ( this.state.eventName )
this.props.sendMessage(this.props.activeTab, this.state.eventName, this.state.messageCollection)
}

Expand Down Expand Up @@ -157,6 +158,9 @@ class MessageSender extends Component {
return true
}

/**
* Add one mesage argument
*/
addMessageArgument () {
const messageCollection = this.state.messageCollection
this.setState({
Expand All @@ -165,6 +169,9 @@ class MessageSender extends Component {
})
}

/**
* Remove a specific message argument
*/
removeMessageArgument () {
const editing = this.state.messageInEditor
const messageCollection = this.state.messageCollection
Expand All @@ -179,6 +186,16 @@ class MessageSender extends Component {
})
}

/**
* Remove all message content
*/
noMessageArgument () {
this.setState({
messageCollection: [],
messageInEditor: 0
})
}

render () {
const state = this.state
const connected = state.tab.connected
Expand Down Expand Up @@ -245,6 +262,12 @@ class MessageSender extends Component {
>
Remove
</button>
<button
onClick={this.noMessageArgument}
className="message-arguments-buttons-button"
>
None
</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 9c4bec1

Please sign in to comment.