Skip to content

Commit

Permalink
feat: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Aug 25, 2024
1 parent 00a5359 commit 0d7e512
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions js/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ export const comment = (() => {
owns.unset(id);
document.getElementById(id).remove();

// todo
document.querySelectorAll('[data-uuids]').forEach((n) => {
document.querySelectorAll('a[onclick="comment.showOrHide(this)"]').forEach((n) => {
const oldUuids = n.getAttribute('data-uuids').split(',');

if (oldUuids.find((i) => i === id)) {
const uuids = oldUuids.filter((i) => i !== id).join(',');
n.setAttribute('data-uuids', uuids);


if (uuids.length === 0) {
n.remove();
} else {
n.setAttribute('data-uuids', uuids);
}
}
});
Expand Down Expand Up @@ -234,7 +234,7 @@ export const comment = (() => {
anchorTag.remove();
}

containerDiv.querySelector('button.ms-auto').insertAdjacentHTML('beforebegin', card.renderReadMore(id, anchorTag ? anchorTag.getAttribute('data-uuids').split(',').concat(uuids) : uuids));
containerDiv.querySelector(`button[onclick="like.like(this)"][data-uuid="${id}"]`).insertAdjacentHTML('beforebegin', card.renderReadMore(id, anchorTag ? anchorTag.getAttribute('data-uuids').split(',').concat(uuids) : uuids));
}

};
Expand Down

0 comments on commit 0d7e512

Please sign in to comment.