Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
);
};
};
static getTextMessage(uid, text, msgType) {
if (msgType == "user") {
return new CometChat.TextMessage(uid, text, CometChat.RECEIVER_TYPE.USER);
} else {
return new CometChat.TextMessage(uid, text, CometChat.RECEIVER_TYPE.GROUP);
}
}
static getTextMessage(uid, text, msgType) {
if (msgType == "user") {
return new CometChat.TextMessage(uid, text, CometChat.RECEIVER_TYPE.USER);
} else {
return new CometChat.TextMessage(uid, text, CometChat.RECEIVER_TYPE.GROUP);
}
}
if (e.target.id === "sendMsgIco" || code === 13) {
//Enter keycode
let receiverID;
let receiverType;
if (this.props.activeConversation.guid !== undefined) {
receiverID = this.props.activeConversation.guid;
receiverType = CometChat.RECEIVER_TYPE.GROUP;
} else if (this.props.activeConversation.uid !== undefined) {
receiverID = this.props.activeConversation.uid;
receiverType = CometChat.RECEIVER_TYPE.USER;
}
var messageText = this.state.newMessage;
var textMessage = new CometChat.TextMessage(
receiverID,
messageText,
CometChat.MESSAGE_TYPE.TEXT,
receiverType
);
if (this.state.editingMessageActive === true) {
this.handleMessageUpdate(receiverID, receiverType, messageText);
} else {
CometChat.sendMessage(textMessage).then(
message => {
this.setState({
newMessage: [],
msghistory: [...this.state.msghistory, message]
});
handleMessageUpdate = (receiverID, receiverType, messageText) => {
let messageId = this.state.showMsgActionID;
let textMessage = new CometChat.TextMessage(
receiverID,
messageText,
receiverType
);
textMessage.setId(messageId);
CometChat.editMessage(textMessage).then(
message => {
let msghistory = this.state.msghistory;
const messageKey = _.findIndex(msghistory, function(m) {
return m.id === messageId;
});
msghistory[messageKey] = message;