diff --git a/files/templates/default.html b/files/templates/default.html
index 6cd578455f..9ceccaa0db 100644
--- a/files/templates/default.html
+++ b/files/templates/default.html
@@ -210,24 +210,20 @@
// New comment counts
- // comment counts format: {"123412": {c: 12, t: 23532456263}}
+ // comment counts format: {"": {c: , t: }}
const COMMENT_COUNTS_ID = "comment-counts"
/**
* Display the number of new comments present since the last time the post was opened
*/
- function showNewCommentCounts(postId, lastTotalComs) {
+ function showNewCommentCounts(postId, newTotal) {
const comments = JSON.parse(localStorage.getItem(COMMENT_COUNTS_ID)) || {}
- console.log(postId)
const lastCount = comments[postId]
- console.log(lastCount)
if (lastCount) {
- const newComments = lastTotalComs - lastCount.c
- console.log('new:', newComments)
+ const newComments = newTotal - lastCount.c
if (newComments > 0) {
document.querySelectorAll(`#post-${postId} .new-comments`).forEach(elem => {
- console.log(elem)
elem.textContent = ` (+${newComments})`
elem.classList.remove("d-none")
})
@@ -250,12 +246,9 @@
const newTotal = lastTotalComs || ((comments[postId] || { c: 0 }).c + 1)
- console.log(newTotal)
comments[postId] = { c: newTotal, t: Date.now() }
window.localStorage.setItem(COMMENT_COUNTS_ID, JSON.stringify(comments))
-
- //TODO: restrict on display unread comments flag
}
/**
@@ -286,7 +279,6 @@
// So it does not slow the load of the main page with the clean up
setTimeout(cleanCache, 500)
}
-
cleanCommentsCache()
diff --git a/files/templates/submission.html b/files/templates/submission.html
index 010cc61585..4325c6245d 100644
--- a/files/templates/submission.html
+++ b/files/templates/submission.html
@@ -747,7 +747,9 @@
document.getElementById('edited_timestamp').title = dateEdited.toString();
{% endif %}
- showNewCommentCounts('{{p.id}}', {{p.comment_count}})
+ {% if (not v or v.highlightcomments) %}
+ showNewCommentCounts('{{p.id}}', {{p.comment_count}})
+ {% endif %}
saveCommentsCount('{{p.id}}', {{p.comment_count}})
})()
diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html
index c17027d7d4..76b6c66203 100644
--- a/files/templates/submission_listing.html
+++ b/files/templates/submission_listing.html
@@ -408,7 +408,9 @@
document.getElementById('edited_timestamp-{{p.id}}').title = dateEdited.toString();
{% endif %}
- showNewCommentCounts('{{p.id}}', {{p.comment_count}})
+ {% if (not v or v.highlightcomments) %}
+ showNewCommentCounts('{{p.id}}', {{p.comment_count}})
+ {% endif %}
})()