Skip to content

feat: solved task#1375

Open
TarasPidkuimukha wants to merge 3 commits intomate-academy:masterfrom
TarasPidkuimukha:develop
Open

feat: solved task#1375
TarasPidkuimukha wants to merge 3 commits intomate-academy:masterfrom
TarasPidkuimukha:develop

Conversation

@TarasPidkuimukha
Copy link
Copy Markdown

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

Great job implementing the core logic for the promises! Your use of Promise.all is excellent. However, one requirement isn't quite met, which needs to be fixed. The resolution message for firstPromise must be exactly First promise was resolved, without the exclamation mark.

Additionally, as a point of improvement, your event listeners are never removed after the promises settle. This can lead to memory leaks. A simple way to handle this is to add the { once: true } option to your addEventListener calls, which automatically cleans them up after they fire once. Please update the promise message to meet the requirement.


✨ 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/scripts/main.js Outdated
);

document.addEventListener('click', () => {
resolve('First promise was resolved!');
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 resolution message for firstPromise doesn't exactly match the requirements. It should be First promise was resolved, without the exclamation mark.

Comment thread src/scripts/main.js Outdated
Comment on lines +19 to +22
document.addEventListener('click', () => {
resolve('First promise was resolved!');
clearTimeout(id);
});
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 event listener is never removed. After the promise settles (either by resolving on click or rejecting on timeout), the listener remains active. It's a best practice to clean up listeners to avoid memory leaks and unintended side effects. You can achieve this easily by adding the { once: true } option to addEventListener, which automatically removes the listener after it has executed once.

Comment thread src/scripts/main.js Outdated
Comment on lines +26 to +33
document.addEventListener('click', () => {
resolve('Second promise was resolved');
});

document.addEventListener('contextmenu', (e) => {
e.preventDefault();
resolve('Second promise was resolved');
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similar to promise1, these event listeners are not removed after the promise resolves. Since the promise only needs to resolve once, consider cleaning them up after the first click event using the { once: true } option in addEventListener.

Comment thread src/scripts/main.js Outdated
Comment on lines +37 to +46
document.addEventListener('click', () => {
resolve('Third promise was resolved');
});
});

const rightClickPromise = new Promise((resolve, reject) => {
document.addEventListener('contextmenu', (e) => {
e.preventDefault();
resolve();
});
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 listeners for leftClickPromise and rightClickPromise also remain active after they've fired. Since Promise.all only requires each promise to resolve once, these listeners should be removed after their respective events occur. The { once: true } option is a great fit here as well.

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

Thanks for the update and for implementing the { once: true } suggestion—that's a great improvement!

However, this requires changes because the main issue from the previous review still needs to be addressed. The firstPromise must resolve with the exact message First promise was resolved as specified in the requirements. Your code currently resolves it with First promise was resolved!, and this extra exclamation mark is causing the tests to fail.

Please correct this string in src/scripts/main.js to move forward. Looking forward to your next submission!


✨ 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/scripts/main.js Outdated
);

document.addEventListener('click', () => {
resolve('First promise was resolved!');
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 resolution message here doesn't match the requirement exactly. According to the task description, it should be First promise was resolved, without the exclamation mark.

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 task! I am approving your solution. You've perfectly implemented all the requirements for the promises, and your logic for handling the click events, timeouts, and combining promises with Promise.all is spot-on. It's great to see you successfully addressed the feedback from the previous review. The code is clean, functional, and meets all specifications. Keep up the fantastic work!


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

Footnotes

  1. Rate AI review example

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