Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
This is a strong submission with a well-structured server. However, changes are needed for the room deletion feature, as it contains a critical bug that breaks functionality for users.
In src/controllers/socketController.js, when a room is deleted, users are moved to the 'General' room, but their currentRoom state on the server is not updated. This inconsistency prevents those users from sending any further messages. The issue is that io.in(roomId).socketsJoin(...) only changes the socket's subscription but doesn't update the currentRoom variable held in the socket's closure.
To fix this, consider emitting a dedicated event to the clients in the deleted room. The clients can then handle this event by emitting a room:join event for the 'General' room, which will correctly update their state on both the client and server. Once you resolve this state management issue, the application should be fully functional.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
src/controllers/socketController.js
Outdated
| io.in(roomId).socketsJoin(store.DEFAULT_ROOM_ID); | ||
| io.in(roomId).socketsLeave(roomId); |
There was a problem hiding this comment.
This approach to moving users from a deleted room is problematic. While socketsJoin and socketsLeave correctly change the socket's room subscription at the socket.io level, they don't update the currentRoom variable (defined on line 8) for each affected socket connection. This leads to a state inconsistency where the server thinks the user is still in the old room, causing subsequent actions like sending a message to fail.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this submission! I am approving your solution as you've successfully addressed the critical bug with room deletion. The application is now fully functional, correctly synchronizing state between the client and server. Your code is well-structured, clean, and meets all the specified requirements. Great job!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Description