Skip to content

Commit

Permalink
feat: refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Jul 28, 2024
1 parent 5baf7a4 commit 0c9729b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
4 changes: 3 additions & 1 deletion js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ export const card = (() => {
};

const fetchTracker = (comment) => {
comment.comments.map((c) => fetchTracker(c));
comment.comments.forEach((c) => {
fetchTracker(c);
});

if (comment.ip === undefined || comment.user_agent === undefined || comment.is_admin || tracker.has(comment.ip)) {
return;
Expand Down
27 changes: 16 additions & 11 deletions js/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,23 +254,28 @@ export const comment = (() => {
}

const uuids = util.extractUUIDs(res.data);
const arr = showHide.get('hidden');
uuids.map((c) => {
if (!arr.find((item) => item.uuid === c)) {
arr.push({
uuid: c,
show: false,
});
}
});
showHide.set('hidden', arr);
showHide.set('hidden', (() => {
let arrHidden = showHide.get('hidden');
uuids.forEach((c) => {
if (!arrHidden.find((item) => item.uuid === c)) {
arrHidden.push({
uuid: c,
show: false,
});
}
});

return arrHidden;
})());

comments.innerHTML = res.data.map((comment) => card.renderContent(comment)).join('');

uuids.forEach((c) => {
like.setTapTap(c);
});
res.data.map((c) => card.fetchTracker(c));
res.data.forEach((c) => {
card.fetchTracker(c);
});
});
};

Expand Down

0 comments on commit 0c9729b

Please sign in to comment.