How to use the @cometchat-pro/chat.CometChat.markAsRead 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 / components / message / CCMessageBox.js View on Github external
markAsRead(msg) {
    if (msg.receiverType == "user") {
      if ((msg !== undefined && msg.readAt == undefined) && (msg.sender.uid == this.props.activeUser.id)) {
        CometChat.markAsRead(msg.id, msg.sender.uid, msg.receiverType);
      }
    } else {
      if ((msg !== undefined && msg.readByMeAt == undefined && msg.sender.uid !== this.props.loggedUid) && (msg.receiver == this.props.activeUser.id)) {
        CometChat.markAsRead(msg.id, msg.receiver, msg.receiverType);
      }
    }
  }
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / components / message / CCMessageBox.js View on Github external
markAsRead(msg) {
    if (msg.receiverType == "user") {
      if ((msg !== undefined && msg.readAt == undefined) && (msg.sender.uid == this.props.activeUser.id)) {
        CometChat.markAsRead(msg.id, msg.sender.uid, msg.receiverType);
      }
    } else {
      if ((msg !== undefined && msg.readByMeAt == undefined && msg.sender.uid !== this.props.loggedUid) && (msg.receiver == this.props.activeUser.id)) {
        CometChat.markAsRead(msg.id, msg.receiver, msg.receiverType);
      }
    }
  }
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / store / reducer / message.js View on Github external
const copyPSMessageState = Object.assign({}, state.messages[index]);
        copyPSMessageState.message.push(action.message);
        const PSMessageState = update(state, {messages: { index: { $set: [copyPSMessageState] } }});
        return PSMessageState;
      }
    break;

    case "updateMessageList":
      if(action.tags == "user"){
        var array = action.messages;
        var incomingMessages = array.filter(function(msg) {
          return msg.sender.uid == action.uid;
        });
        var lastMessage = incomingMessages[incomingMessages.length - 1];
        if (lastMessage !== undefined && lastMessage.readAt == undefined) {
          CometChat.markAsRead(lastMessage.id,lastMessage.sender.uid,lastMessage.receiverType);
        }
      }else{
        var array = action.messages;
        var incomingMessages = array.filter(function(msg) {
          return msg.sender.uid != action.loggedInUser;
        });
        var lastMessage = incomingMessages[incomingMessages.length - 1];
        if (lastMessage !== undefined && lastMessage.readByMeAt == undefined) {
          CometChat.markAsRead(lastMessage.id,lastMessage.receiver,lastMessage.receiverType);
        }
      }

      let index1 = newState.messages.findIndex(
        userMessage => userMessage.muid === action.uid
      );
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / store / reducer / message.js View on Github external
var array = action.messages;
        var incomingMessages = array.filter(function(msg) {
          return msg.sender.uid == action.uid;
        });
        var lastMessage = incomingMessages[incomingMessages.length - 1];
        if (lastMessage !== undefined && lastMessage.readAt == undefined) {
          CometChat.markAsRead(lastMessage.id,lastMessage.sender.uid,lastMessage.receiverType);
        }
      }else{
        var array = action.messages;
        var incomingMessages = array.filter(function(msg) {
          return msg.sender.uid != action.loggedInUser;
        });
        var lastMessage = incomingMessages[incomingMessages.length - 1];
        if (lastMessage !== undefined && lastMessage.readByMeAt == undefined) {
          CometChat.markAsRead(lastMessage.id,lastMessage.receiver,lastMessage.receiverType);
        }
      }

      let index1 = newState.messages.findIndex(
        userMessage => userMessage.muid === action.uid
      );

      if(index1 != -1){
        const copyMessageState = Object.assign({}, state.messages[index1]);
        action.messages.map(msg => {copyMessageState.message.push(msg);});
        const copyMessagesState = Object.assign({}, state.messages);
        const NPLMessageState = update(state, {messages: { index: { $set: [copyMessageState] } }});
        return NPLMessageState;
      }else{
        var tempObj = {
          muid: action.uid,