Skip to content

add solution#1353

Open
GabrielSpelchuk wants to merge 2 commits intomate-academy:masterfrom
GabrielSpelchuk:develop
Open

add solution#1353
GabrielSpelchuk wants to merge 2 commits intomate-academy:masterfrom
GabrielSpelchuk:develop

Conversation

@GabrielSpelchuk
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 setting up the promises and the UI feedback system! The implementation for thirdPromise is spot on.

However, changes are needed for firstPromise and secondPromise due to a critical issue with the event listeners. Using the { once: true } option causes the listener to be removed after the very first click, no matter which mouse button is used. For example, if a user right-clicks first, the listener for firstPromise is removed, and any later left-clicks are ignored, causing the promise to be incorrectly rejected by the timeout.

To fix this, please remove { once: true } and instead, manually remove the event listener from within the handler function only after the condition to resolve the promise has been met.


✨ 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
resolve('First promise was resolved');
}
},
{ once: true },
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 { once: true } option causes a bug here. It removes the event listener after the very first click, regardless of which button was pressed. If that first click is not a left click (e.g., a right click), the listener is removed, and subsequent left clicks won't be detected. This will cause the promise to be incorrectly rejected by the timeout instead of being resolved.

Comment thread src/scripts/main.js Outdated
resolve('Second promise was resolved');
}
},
{ once: true },
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 the firstPromise, using { once: true } is incorrect here. If the user's first click is a middle click, the listener will be removed, and the promise will never resolve because it can no longer listen for the required left or right clicks. The event listener should remain active until either a left or right click occurs.

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'm happy to approve your solution. You've successfully implemented all the requirements for the three promises, and the logic for handling the different click events and timeouts is spot-on. Most importantly, you've perfectly addressed the previous feedback by manually removing the event listeners after the promises are settled. The code is clean, correct, and works exactly as expected. 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

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