Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Открывается и закрывается (часть 2) #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nkirkr
Copy link

@nkirkr nkirkr commented Dec 17, 2024

@keksobot keksobot changed the title module8-task2 Открывается и закрывается (часть 2) Dec 17, 2024
@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Dec 17, 2024

const closePostModal = () => {
postModal.classList.add('hidden');
closeModalBtn.removeEventListener('click', closePostModal);
document.body.classList.remove('modal-open');
};

const clearComments = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

из названия функции не очевидно ее назначение

const insertPostComments = (commentsArr) => {
const checkCommentsLength = () => {
commentsCount.textContent = currentCount;
if (commentsCount.textContent === commentsTotal.textContent) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

У вас есть глобальные переменные в которых хранятся значения из условия, используйте их

const insertPostComments = (newComments) => {
comments = newComments;
clearComments();
insertMoreComments(comments);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Переменная comments глобальная, нет нужды передавать ее в кач-ве параметра

postModal.querySelector('.social__comment-count').classList.add('hidden');
postModal.querySelector('.comments-loader').classList.add('hidden');
postComments.innerHTML = '';
clearComments();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Дублирование кода, вызов clearComments уже есть внутри insertPostComments

@@ -54,4 +81,6 @@ document.addEventListener('keydown', (evt) => {
escKeypress(evt, closePostModal);
});

export {findPostContent};
loadMore.addEventListener('click', () => insertMoreComments(comments));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Переменная comments глобальная, нет нужды передавать ее в кач-ве параметра

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.

3 participants