Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Handle text message
senderID = textMessage.sender.uid;
messageId = textMessage.id;
if (senderID !== this.props.subjectUID) {
CometChat.markMessageAsRead(
textMessage
);
}
this.setState({
msghistory: [...this.state.msghistory, textMessage]
});
this.props.handleOnRecentMessageSent(messageId);
} else if (
textMessage.receiverType === CometChat.RECEIVER_TYPE.GROUP &&
textMessage.receiverId === this.props.activeConversation.guid
) {
if(textMessage.sender.uid !== this.props.subjectUID)
{
// Handle text message
senderID = textMessage.sender.uid;
messageId = textMessage.id;
CometChat.markMessageAsRead(textMessage);
this.props.handleOnRecentMessageSent(messageId);
this.setState({
msghistory: [...this.state.msghistory, textMessage]
});
}
}
return dispatch => {
let messageType = CometChat.MESSAGE_TYPE.TEXT;
let receiverType = CometChat.RECEIVER_TYPE.USER;
let textMessage = new CometChat.TextMessage(
receiverID,
messageText,
messageType,
receiverType
);
textMessage.setId(messageId);
CometChat.editMessage(textMessage).then(
message => {
dispatch(editMessage(message));
},
error => {
console.log("Message editing failed with error:", error);
}
);
};
handleTextInputChange = e => {
this.setState({ newMessage: e.target.value });
if (this.props.activeConversation.uid !== undefined) {
let receiverId = this.props.activeConversation.uid;
let receiverType = CometChat.RECEIVER_TYPE.USER;
let typingNotification = new CometChat.TypingIndicator(
receiverId,
receiverType
);
if (e.target.value === "") CometChat.endTyping(typingNotification);
else CometChat.startTyping(typingNotification);
} else if (this.props.activeConversation.guid !== undefined) {
let receiverId = this.props.activeConversation.guid;
let receiverType = CometChat.RECEIVER_TYPE.GROUP;
let typingNotification = new CometChat.TypingIndicator(
receiverId,
receiverType
endTyping=()=>{
if(this.props.activeMessageType == "user"){
let receiverId = this.props.activeUser;
let receiverType = CometChat.RECEIVER_TYPE.USER;
let metadata = {
text : ""
};
let typingNotification = new CometChat.TypingIndicator(receiverId,receiverType,metadata);
CometChat.endTyping(typingNotification);
}
}
{conversations.map(c => (
))}