Messages are displayed as read before reading
Summary
Was reported in https://foodsharing.freshdesk.com/a/tickets/1057
Chat message are sometimes marked as read even though they have not been opened. That's a problem if people miss important messages.
Steps to reproduce
Actors: RECEIVER and SENDER in separate sessions.
- Preparation: Set all conversations of user "Two" to unread in phpmyadmin:
update `fs_foodsaver_has_conversation` set unread=1 where foodsaver_id=2
- SENDER:
- Log in as storemanager1@example.com,
- send a message to user "Two".
- RECEIVER:
- Log in as two@example.com
- -> New messages count in the navbar should be 20
- Click on the navbar messages dropdown, then click on the top message. (should be from user "Three")
- -> The chat popup with user "Two" opens and the message is marked as read. (New messages count should go down to 19)
- Close the chat window.
- Reload the page.
- -> The new messages count should be back to 20 and the conversation with user "Three" should not be in the messages list in the navbar. (Because it is now read and sorted after all the unread conversations)
- SENDER: send another message to user "Two".
- RECEIVER:
- -> The new message count should go up to 21 as the new message is pushed via websocket.
- -> The conversation is shown at the top in the navbar list, and is displayed as unread, but was actually marked read in the database.
- Reload the page.
- -> The new message count is back to 20.
- -> The conversation with user "Three" is not shown in the list, because it is marked read. This can be confirmed in the database:
select `fs_foodsaver_has_conversation` where foodsaver_id=2 order by unread
What is the current bug behavior?
Messages are marked as read
What is the expected correct behavior?
They should be marked as new / "not yet read"
Relevant error messages and/or screenshots
...
Possible fixes
...
Edited by Neriton