Skip to content

Commit

Permalink
feat: add touch event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Dec 28, 2024
1 parent 38ad812 commit 1cdbebb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const card = (() => {
const renderContent = (comment, is_parent) => {
return `
<div ${renderHeader(comment, is_parent)} id="${comment.uuid}" style="overflow-wrap: break-word !important;">
<div id="body-content-${comment.uuid}" data-tapTime="0" data-liked="false" ontouchend="like.tapTap(this)">
<div id="body-content-${comment.uuid}" data-tapTime="0" data-liked="false" role="button" tabindex="0">
${renderBody(comment, is_parent)}
</div>
${renderTracker(comment)}
Expand Down
10 changes: 10 additions & 0 deletions js/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export const comment = (() => {
showHide.set('hidden', traverse(res.data, showHide.get('hidden')));
comments.innerHTML = res.data.map((c) => card.renderContent(c)).join('');
res.data.forEach(fetchTracker);
res.data.forEach(addEventLike);

return res;
});
Expand Down Expand Up @@ -405,6 +406,15 @@ export const comment = (() => {
anchor.setAttribute('data-show', isCollapsed ? 'true' : 'false');
};

const addEventLike = (comment) => {
if (comment.comments) {
comment.comments.forEach(addEventLike);
}

const bodyLike = document.getElementById(`body-content-${comment.uuid}`);
bodyLike.addEventListener('touchend', () => like.tapTap(bodyLike));
};

const fetchTracker = (comment) => {
if (!session.isAdmin()) {
return;
Expand Down

0 comments on commit 1cdbebb

Please sign in to comment.