Rocket.Chat
Rocket.Chat copied to clipboard
fix: Deletion of 1st message in a thread causes notification to be up without showing why.
Proposed changes (including videos or screenshots)
This PR fixes the issue that would arise all the times the first (and only) message of a thread would get deleted. What was happening is that, we were not checking, on deletion, if all the messages of a thread had been deleted, which was making the UI feel unresponsive, since the 'Following' bell would show as if there were unread messages even if the message was deleted. So, now, we do a couple checks to ensure consistency:
- We decrease the counter of the number of thread messages in the parent message
- We remove unread from the subscription of the deleted message, and, if some message was updated, we notify the client to refresh that data.
- If the number of thread messages of the parent message is 0, we also notify the client to update the parent message, so we avoid showing that there are 1 thread message even if it was deleted.
Issue(s)
Steps to test or reproduce
You are going to need two users, let's call them user A and B, they both must be at the same room for you to be able to test.
- As user A send a message in the room
- As user B add a thread message in the room
- As user B remove the thread message
- Click on the user A browser so the websocket update takes place
Expected:
- The thread should show the "View thread" button, and it show there is 0 replies, and there should be no visual representation of an unread message