diff --git a/files/assets/js/comments.js b/files/assets/js/comments.js index 966f2c02b..4e7c0a903 100644 --- a/files/assets/js/comments.js +++ b/files/assets/js/comments.js @@ -56,4 +56,22 @@ function expandMarkdown(t,id) { let val = t.getElementsByTagName('span')[0] if (val.innerHTML == 'View source') val.innerHTML = 'Hide source' else val.innerHTML = 'View source' -}; \ No newline at end of file +}; + +function commentsAddUnreadIndicator(commentIds) { + commentIds.forEach(element => { + const commentOnly = document.getElementById(`comment-${element}-only`); + if (!commentOnly) { + console.warn(`Couldn't find comment (comment ID ${element}) in page while attempting to add an unread indicator.`); + return; + } + if (commentOnly.classList.contains("unread")) return; + commentOnly.classList.add("unread"); + const commentUserInfo = document.getElementById(`comment-${element}`)?.querySelector(".comment-user-info"); + if (!commentUserInfo) { + console.warn(`Couldn't find comment user info (comment ID ${element}) in page while attempting to add an unread indicator.`); + return; + } + commentUserInfo.innerHTML += "~new~"; + }); +} diff --git a/files/templates/comments.html b/files/templates/comments.html index 879709ef6..793ec7d87 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -201,23 +201,23 @@ + {# See https://github.com/themotte/rDrama/pull/642#issuecomment-1646649781 for info on this section of the code #}