How to make a difference between messages I sent and others I received when reading messages

32 Views Asked by At

I use read message API to get all messages for one conversation between two users. The result is the following (check image). enter image description here

How I am supposed to know what are the messages I have sent and others I received?

The purpose is to display the conversation like in the picture.enter image description here

This is how I read messages sent between two users.

function readConversationWithUser(userId){
  return new Promise((resolve) => {
    var messageSession = api.readDbSession(userId.toString(), 0, null,
    function on_read(count) {
      var messages = messageSession.getMessages();
      resolve(messages);
    });

    messageSession.enableReadReceipt(true);
    messageSession.read(100);
  });
}

userId is my user's unique address.

Thank you very much for your help!

PS: Is there any library to use with angular application or typescript?

0

There are 0 best solutions below