Skip to content

London | 26-Jul-SDC | Roman Sanaye | Sprint 2 | Chat App CYF-1162 - #114

Open
RomanSanaye wants to merge 11 commits into
CodeYourFuture:mainfrom
RomanSanaye:chatApp-non-live
Open

London | 26-Jul-SDC | Roman Sanaye | Sprint 2 | Chat App CYF-1162#114
RomanSanaye wants to merge 11 commits into
CodeYourFuture:mainfrom
RomanSanaye:chatApp-non-live

Conversation

@RomanSanaye

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

Changelist

This PR improves the chat application by adding client identification, message alignment, reactions, and long polling.

Changes made

  • Added a persistent clientId using localStorage.
  • Messages sent by the current client appear on the right.
  • Messages from other clients appear on the left.
  • Added like and dislike reactions with reaction counts.
  • Implemented long polling to receive new messages.
  • Added backend validation for messages and client IDs.
  • Refactored the backend notification logic.

Deployed application

Frontend:
https://0l7lqpbmvhm5ffxxppby1k4f.trainees.hosting.cyf.academy/

Backend:
https://x2fkdg4qtvw2zk6tfpgmud7g.trainees.hosting.cyf.academy/

@RomanSanaye RomanSanaye added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 2, 2026

@LonMcGregor LonMcGregor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This app works well, you have added a like/dislike feature that works.
The code is well organised and easy to read.
I have a couple of questions to follow up on.

<h1>Chat App</h1>
</header>

<main id="messages" class="messages"></main>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good use of semantic HTML

Comment thread chat-app/frontend/app.js Outdated
// Get messages from server
async function getMessages() {
const response = await fetch(
`https://x2fkdg4qtvw2zk6tfpgmud7g.trainees.hosting.cyf.academy/messages?since=${lastMessageId}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You repeat the live domain string in multiple different places. Imagine the domain changed - is there a way you could refactor the code so that changing this string would be easier?

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.

Hello @LonMcGregor ,
Thanks! I’ve moved the repeated domain into an API_URL constant, so it only needs to be changed in one place.


// Send update to clients waiting for new messages
function notifyClients(update) {
while (callbacksForNewMessages.length > 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you explain the approach you are using here for "callbacks" - how do you intend this to work?

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.

I’m using callbacks to implement long polling. When a client requests /messages and there are no new messages, I store a callback containing res.json() in callbacksForNewMessages instead of responding immediately. When a new message arrives, notifyClients(update) takes the stored callbacks and calls them with the update, which sends the new message to the waiting clients.

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Sep 7, 2026
@RomanSanaye RomanSanaye added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 8, 2026
@RomanSanaye RomanSanaye changed the title London | 26-Jul-SDC | Roman Sanaye | Sprint 2 | Chat App London | 26-Jul-SDC | Roman Sanaye | Sprint 2 | Chat App CYF-1162 Sep 8, 2026
@LonMcGregor

Copy link
Copy Markdown
Contributor

Thanks for answering the questions. Using a constant is a better approach here, good idea. The task is complete now, good work

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

1 similar comment
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

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

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants