Skip to content

Commit

Permalink
Delete messages when edited to have no content
Browse files Browse the repository at this point in the history
Fixes #311.
  • Loading branch information
bates64 committed May 22, 2018
1 parent 8a20f59 commit 5d1bc61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion packages/client/js/Messages/Message/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ class Message extends Component {
content={message.text}

sendMessage={async text => {
console.log(text)

this.setState({editing: null})
await message.edit(text)

if (text.trim().length === 0) {
await message.delete()
} else {
await message.edit(text)
}
}}
cancel={() => this.setState({editing: null})}
/>
Expand Down
6 changes: 4 additions & 2 deletions packages/client/js/Messages/MessageEditor/MessageEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ class MessageEditor extends Component {
}

sendMessage = message => {
if (!message) return
//if (!message) return

let messageFormatted = this.parseMarkdown(message)
this.props.sendMessage(messageFormatted)
}

sendMessageFromInput = () => {
if (this.state.message === '') return false
//if (this.state.message === '') return false

console.log(this.state)

this.sendMessage(this.state.message)
this.setState({
Expand Down
2 changes: 1 addition & 1 deletion packages/client/js/Messages/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class Messages extends Component {
}

sendMessage = content => {
this.props.channel.sendMessage(content)
if (content) this.props.channel.sendMessage(content)
}

render({ channel }, { messages, isLoading, me }) {
Expand Down

0 comments on commit 5d1bc61

Please sign in to comment.