From 1a407090d9a91468a72b6d6a3ed2c2ee686cefe2 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sat, 22 Jul 2023 13:34:39 -0500 Subject: [PATCH] Also do this on submissions too... --- files/templates/submission.html | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/files/templates/submission.html b/files/templates/submission.html index 4a64610fc..fd2057411 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -489,19 +489,20 @@ comments = JSON.parse(localStorage.getItem("old-comment-counts")) || {} lastCount = comments['{{p.id}}'] - if (lastCount) - { - {% for c in p.comments %} + + var commentsToCheck = [ + {% for c in p.comments -%} {% if not (v and v.id==c.author_id) and not c.voted %} - if ({{c.created_utc*1000}} > lastCount.t) - try { - document.getElementById("comment-{{c.id}}-only").classList.add('unread') - document.getElementById("comment-{{c.id}}").querySelector(".comment-user-info").innerHTML += "~new~"; - } - catch(e) {} + [{{c.id}}, {{c.created_utc * 1000}}], {% endif %} {% endfor %} - } + ]; + + commentsToCheck = commentsToCheck.filter(comment => { + return comment[1] > lastCount.t + }).map(comment => comment[0]); + + if (lastCount) commentsAddUnreadIndicator(commentsToCheck); collapsedCommentStorageApply(); }