Repository navigation
Conversation
- Added backend with Express server and message handling routes - Implemented message sending, fetching, and reacting functionalities - Created frontend HTML structure for chat interface - Developed JavaScript for message rendering and user interactions - Styled chat application with CSS for better user experience
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- Added package.json for backend with necessary dependencies (express, cors, crypto). - Implemented server.js for handling message retrieval, sending, and reactions with long-polling support. - Created index.html for the frontend chat interface with a message input area and display for chat messages. - Developed script.js to manage message fetching, sending, and user interactions (like, dislike, reply). - Styled the chat application with style.css for a user-friendly interface.
LonMcGregor
left a comment
There was a problem hiding this comment.
Good start, but I encountered some issues during testing. I also have some questions about your code.
Part of the task is to deploy the app. Is the chat app deployed anwhere we can test it? It's usually a good idea to include this in the PR text.
| <script src="script.js" defer></script> | ||
| </head> | ||
|
|
||
| <body> |
There was a problem hiding this comment.
Did you try running the lighthouse tool? Does it offer any suggestions for accessibility fixes?
There was a problem hiding this comment.
I did some changes and score is 100 now. @LonMcGregor
There was a problem hiding this comment.
When trying to self-deploy the frontend, I get a couple of errors. A CORS policy error, and a error with long polling. Do you also see these? Is there something I need to configure?
| const messagesById = new Map(messages.map((msg) => [String(msg.id), msg])); | ||
| const waitingClients = []; | ||
|
|
||
| // Date.now() aynı milisaniyede çakışabilir, timestamp'leri tekilleştiriyoruz |
There was a problem hiding this comment.
As a general suggestion, if you are developing code that will be read by other english speakers it's a good idea to make your comments english as well.
| return lastTimestamp; | ||
| } | ||
|
|
||
| function releaseWaitingClients() { |
There was a problem hiding this comment.
Can you explain what releaseWaitingClients is for?
There was a problem hiding this comment.
releaseWaitingClients() handles clients waiting on a long-polling /getMessages request. When a message is sent or a reaction changes, it clears their timeouts and immediately responds with messages newer than each client’s since timestamp. This lets clients receive updates without continuously polling. @LonMcGregor
| return; | ||
| } | ||
|
|
||
| if (!longPoll) { |
There was a problem hiding this comment.
How are you using the longPoll query parameter here? What's the difference of if it is true or false?
There was a problem hiding this comment.
The longPoll query parameter controls what happens when there are no messages newer than since. If it’s false, the server immediately responds with an empty array. If it’s true, the server keeps the request open for up to 25 seconds and responds when an update arrives—or returns an empty array when the timeout expires. If new messages already exist, it responds immediately either way. @LonMcGregor
| ); | ||
|
|
||
| if (likeButton) { | ||
| likeButton.textContent = `👍 ${message.likes || 0}`; |
There was a problem hiding this comment.
Generating the like text is re-used multiple times in the app, is that a maintainable approach?
There was a problem hiding this comment.
You’re right—the reaction button text and accessible label were duplicated. I’ve moved that logic into updateReactionButton() and now use it both when messages are first rendered and when reaction counts update. This keeps both paths consistent.
Learners, PR Template
Self checklist
Task code
Task ID : CYF-1162
Features:
Send chat messages
View existing message history
Reply message
Like and dislike messages