Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active August 12, 2019 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duytq94/9e522ee03d063dd317a8c4c94c69f9a5 to your computer and use it in GitHub Desktop.
Save duytq94/9e522ee03d063dd317a8c4c94c69f9a5 to your computer and use it in GitHub Desktop.
onSendMessage = (content, type) => {
if (this.state.isShowSticker && type === 2) {
this.setState({
isShowSticker: false
})
}
if (content.trim() === '') {
return
}
const timestamp = moment()
.valueOf()
.toString()
const itemMessage = {
idFrom: this.currentUserId,
idTo: this.currentPeerUser.id,
timestamp: timestamp,
content: content.trim(),
type: type
}
myFirestore
.collection(AppString.NODE_MESSAGES)
.doc(this.groupChatId)
.collection(this.groupChatId)
.doc(timestamp)
.set(itemMessage)
.then(() => {
this.setState({
inputValue: ''
})
})
.catch(err => {
this.props.showToast(0, err.toString())
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment