How to use the @cometchat-pro/chat.CometChat.MESSAGE_TYPE 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 / components / cometchat / ChatBody.jsx View on Github external
receiverType = CometChat.RECEIVER_TYPE.GROUP;
    } else if (this.props.activeConversation.uid !== undefined) {
      otherUID = this.props.activeConversation.uid;
      receiverType = CometChat.RECEIVER_TYPE.USER;
    }

    let messageType = CometChat.MESSAGE_TYPE.MEDIA;

    if (fileType === MESSAGE_TYPE_IMAGE)
      messageType = CometChat.MESSAGE_TYPE.IMAGE;
    else if (fileType === MESSAGE_TYPE_VIDEO)
      messageType = CometChat.MESSAGE_TYPE.VIDEO;
    else if (fileType === MESSAGE_TYPE_AUDIO)
      messageType = CometChat.MESSAGE_TYPE.AUDIO;
    else if (fileType === MESSAGE_TYPE_FILE)
      messageType = CometChat.MESSAGE_TYPE.FILE;

    var file = document.getElementById("attachment-type-" + fileType).files[0];

    var mediaMessage = new CometChat.MediaMessage(
      otherUID,
      file,
      messageType,
      receiverType
    );
    CometChat.sendMediaMessage(mediaMessage).then(
      message => {
        // Message sent successfully.
        this.setState({
          showAttachmentOptions: !this.state.showAttachmentOptions,
          msghistory: [...this.state.msghistory, message]
        });
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 / components / message / CCMessageFooter.js View on Github external
getFileGallery = e => {
    var ele = document.getElementById("ccMessageInputGallery");
    var files = ele.files;
    for (let i = 0; i < files.length; i++) {
      const file = files[i];
      this.sendMediaMessage(file,CometChat.MESSAGE_TYPE.IMAGE);
    }
    this.toggleAttachMenu();
  };
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / components / message / CCMessageFooter.js View on Github external
getFile = e => {
    var ele = document.getElementById("ccMessageInputFile");
    var files = ele.files;
    for (let i = 0; i < files.length; i++) {
      const file = files[i];
      this.sendMediaMessage(file,CometChat.MESSAGE_TYPE.FILE);
    }
    this.toggleAttachMenu();
  }
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / components / message / CCMessageFooter.js View on Github external
getFileAudio=e=>{
    var ele = document.getElementById("ccMessageInputAudio");
    var files = ele.files;
    for (let i = 0; i < files.length; i++) {
      const file = files[i];
      this.sendMediaMessage(file,CometChat.MESSAGE_TYPE.AUDIO);
    }
    this.toggleAttachMenu();
  }
github cometchat-pro-samples / javascript-reactjs-chat-app / src / components / cometchat / ChatBody.jsx View on Github external
handleAttachment = (fileType = MESSAGE_TYPE_MEDIA) => {
    let otherUID;
    let receiverType;

    if (this.props.activeConversation.guid !== undefined) {
      otherUID = this.props.activeConversation.guid;
      receiverType = CometChat.RECEIVER_TYPE.GROUP;
    } else if (this.props.activeConversation.uid !== undefined) {
      otherUID = this.props.activeConversation.uid;
      receiverType = CometChat.RECEIVER_TYPE.USER;
    }

    let messageType = CometChat.MESSAGE_TYPE.MEDIA;

    if (fileType === MESSAGE_TYPE_IMAGE)
      messageType = CometChat.MESSAGE_TYPE.IMAGE;
    else if (fileType === MESSAGE_TYPE_VIDEO)
      messageType = CometChat.MESSAGE_TYPE.VIDEO;
    else if (fileType === MESSAGE_TYPE_AUDIO)
      messageType = CometChat.MESSAGE_TYPE.AUDIO;
    else if (fileType === MESSAGE_TYPE_FILE)
      messageType = CometChat.MESSAGE_TYPE.FILE;

    var file = document.getElementById("attachment-type-" + fileType).files[0];

    var mediaMessage = new CometChat.MediaMessage(
      otherUID,
      file,
      messageType,
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / components / message / CCMessageFooter.js View on Github external
recieveCaptureImage = (data) =>{
    let fileObject = utils.dataURLtoFile(data, 'a.png')
    this.closeModalHandler();
    this.toggleAttachMenu();
    this.sendMediaMessage(fileObject,CometChat.MESSAGE_TYPE.IMAGE);
  }
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / components / message / CCMessage.js View on Github external
let messageStatus=null;
    if(props.msgData.receiverType != "group"){
        if(props.msgData.readAt != undefined){
            messageStatus = (<span></span>);
        }else{
            if(props.msgData.deliveredAt != undefined){
                messageStatus = (<span></span>);
            }else{
                if(props.msgData.sentAt != undefined){
                    messageStatus = (<span></span>);
                }
            }
        }
    }
    switch(props.msg.msgType){
        case CometChat.MESSAGE_TYPE.IMAGE : {
            return (
                <div>
                    <div>
                        <div>
                            <span>{util.convertStringToDate(props.msg.sendAt)}</span>
                            <img src="{props.msg.data.url}/" class="">
                            {messageStatus}
                        </div>
                    </div>
                </div>       
            );
        } break;

        case CometChat.MESSAGE_TYPE.VIDEO : {
            return (