How to use the @cometchat-pro/chat.CometChat.TextMessage function in @cometchat-pro/chat

To help you get started, we’ve selected a few @cometchat-pro/chat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / store / actions / cc_action.js View on Github external
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);
      }
    );
  };
};
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / lib / cometchat / ccManager.js View on Github external
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);
    }
  }
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / lib / cometchat / ccManager.js View on Github external
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);
    }
  }
github cometchat-pro-samples / javascript-reactjs-chat-app / src / components / cometchat / ChatBody.jsx View on Github external
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]
            });
github cometchat-pro-samples / javascript-reactjs-chat-app / src / components / cometchat / ChatBody.jsx View on Github external
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;