Skip to content

impl node_chat#196

Open
DimasSavchenko wants to merge 2 commits into
mate-academy:masterfrom
DimasSavchenko:develop
Open

impl node_chat#196
DimasSavchenko wants to merge 2 commits into
mate-academy:masterfrom
DimasSavchenko:develop

Conversation

@DimasSavchenko
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Excellent work on this chat application! I am approving your solution as it meets all the project requirements. The client and server are well-implemented, with a clean UI and solid functionality for user management, messaging, and room controls.

I have a couple of suggestions for future improvement:

  • In client/src/App.jsx, the success toast for renaming a room appears before server confirmation. Moving this toast into the socket.on('roomRenamed', ...) handler would prevent misleading feedback if the server encounters an error.
  • The callback function in your socket.emit('createRoom', ...) call is currently dead code because the server doesn't use an acknowledgment. You could remove this callback on the client and the unused ack parameter on the server to make the code cleaner.

These are minor points in what is an otherwise very well-executed project. Great job!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread client/src/App.jsx Outdated
Comment on lines +153 to +163
socket.emit('createRoom', cleaned, (response) => {
if (!response?.ok) {
const message = response?.error || 'Failed to create room';
setError(message);
showToast(message, 'error');
return;
}

showToast('Room created', 'success');
joinRoom(response.roomId);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server-side 'createRoom' handler doesn't use an acknowledgment callback, so this callback function will never be executed. The logic within this callback is effectively dead code. Fortunately, the necessary logic is correctly implemented in the 'roomCreated' event listener. Consider removing this callback from the socket.emit call.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

Comment thread client/src/App.jsx Outdated
}

socket.emit('renameRoom', { roomId: currentRoom.id, newName: cleaned });
showToast('Room renamed', 'success');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This success toast is displayed immediately after sending the request to the server, without waiting for confirmation. If an error occurs on the server (e.g., the new room name is invalid or already exists), the user will see a success message followed by an error message. It would be better to move this toast into the socket.on('roomRenamed', ...) event handler to ensure it only appears after the server confirms the action was successful.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved toast to relative handler.

Comment thread src/index.js Outdated
}
});

socket.on('createRoom', (roomName, ack) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ack parameter, which is an acknowledgment callback sent by the client, is defined here but is never called within the function body. Instead of using the callback to confirm room creation, a separate 'roomCreated' event is emitted. While the functionality works correctly because the client listens for this event, the unused parameter can be misleading. Consider either using the ack callback to send the response or removing it from the function signature.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed ack callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants