From b4397c320da48ec091988eb5f68c697a98450637 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 14 Nov 2024 23:17:53 +0200 Subject: [PATCH] fix console error --- files/assets/js/comments_v.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 404c053f4..a9702caac 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -296,9 +296,11 @@ function post_comment(fullname, hide) { if (pids.length) { //need .length, getElementsByClassName is always truthy const pid = pids[pids.length - 1].value const comments = JSON.parse(localStorage.getItem("comment-counts")) - const newTotal = parseInt(comments[pid].c) + 1 - comments[pid] = {c: newTotal, t: comments[pid].t} - localStorage.setItem("comment-counts", JSON.stringify(comments)) + if (comments[pid]) { + const newTotal = parseInt(comments[pid].c) + 1 + comments[pid] = {c: newTotal, t: comments[pid].t} + localStorage.setItem("comment-counts", JSON.stringify(comments)) + } } close_inline_emoji_modal();