rpaschoal / ng-chat

💬 A simple facebook/linkedin lookalike chat module for Angular applications.
MIT License
155 stars 92 forks source link

Is it possible to get an event with destinataryId of the chat window from which the user is typing? #145

Closed ranjeethkrao closed 4 years ago

ranjeethkrao commented 4 years ago

I am using this in a scenario, where same two participants can chat on different 'topics'. So the 'friendsList' in my case is basically the various 'topics'. This makes the fields 'fromId' and 'toId' same. Hence I cannot differentiate to which 'topic' the message was sent (This info is needed in the backend to store the thread topic wise). So I am not able to get the chat window instance (basically the 'destinataryId') from which the participants are sending messages.

Is there any way to get the chat window instance or an event emitting the 'destinatryId' on which the user is typing?

rpaschoal commented 4 years ago

Hi @ranjeethkrao ,

What if instead of having the fromId and toId as the same values, you would define the toId as your topic ID? Then you could implement some logic on your back-end to figure where the messages should be sent to?

rpaschoal commented 4 years ago

On this, when ng-chat triggers your adapter's sendMessage method, you should have the ID of both sender and destinatary within the Message payload.

ranjeethkrao commented 4 years ago

Thanks @rpaschoal, that is exactly how I ended up implementing eventually! Just wanted to know if there was an event which would help me ease this logic.

Anyways thanks for your reply and great job on the ng-chat!