From 814267bd1c3e93f6c3c5788c42b732a5f2eac054 Mon Sep 17 00:00:00 2001 From: epicsam123 <92618898+epicsam123@users.noreply.github.com> Date: Mon, 3 Feb 2025 19:29:31 -0500 Subject: [PATCH] refactor condition, fallback -> originalHTML --- assets/js/comments.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/js/comments.js b/assets/js/comments.js index 986eca9b..79cc25ae 100644 --- a/assets/js/comments.js +++ b/assets/js/comments.js @@ -63,7 +63,7 @@ function show_youtube_replies(event) { function get_youtube_comments() { var comments = document.getElementById('comments'); - var fallback = comments.innerHTML; + var originalHTML = comments.innerHTML; comments.innerHTML = spinnerHTML; var baseUrl = video_data.base_url || '/api/v1/comments/'+ video_data.id @@ -76,7 +76,7 @@ function get_youtube_comments() { url += '&ucid=' + video_data.ucid; } - var onNon200 = function (xhr) { comments.innerHTML = fallback; }; + var onNon200 = function (xhr) { comments.innerHTML = originalHTML; }; if (video_data.params.comments[1] === 'youtube') onNon200 = function (xhr) {}; @@ -142,11 +142,11 @@ function format_count_load_more(content, current_count, total_count) { } function format_count_toggle_replies_button(toggle_reply_button, current_count, total_count, has_more_replies) { - if (has_more_replies) { - if (current_count >= total_count) total_count = '?'; - } else { + if (!has_more_replies) { // Accept the final current count as the total (comments may have been added or removed since loading) total_count = current_count; + } else if (current_count >= total_count) { + total_count = '?'; } if (isRTL) [current_count, total_count] = [total_count, current_count];