Answer the question
In order to leave comments, you need to log in
How to implement the "viewed" status in the chat (opposite messages)?
Can you tell me how to implement the "read" status in chat messages?
Table 2, managing chats and messages .
PS I think to use a radish so that the base does not pull every time.
// v - viewed
$redis->set('v:' . $chat_id, $message_id . '_' . time());
Answer the question
In order to leave comments, you need to log in
Send current AJAX user status. Those. for example, every second (for example!) - ajax request, like the user reads the current dialog, if he has it open - create the 'is_read' field in the messages table and set the value to 1 (read). If closed, requests are not sent.
Also bringing to the ideal - if the user does not perform actions, disable this system with ajax)
Add a third table - message_status.
Store message_id, user_id and read_at in it as a nullable timestamp.
In the chat interface, control messages that fall into the visible area and track the scroll event.
Store the status of the messages in the model on the client and periodically send these updates to the server in the background and page unload if there is anything left.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question