From 5451391502016654aa19bb3c2892e07298fe4f8f Mon Sep 17 00:00:00 2001 From: Samuel Casellas Date: Fri, 10 Jan 2025 12:47:00 -0500 Subject: [PATCH] Incorporate unused "unable to load comments" message --- assets/js/comments.js | 4 ++-- assets/js/community.js | 2 +- assets/js/watch.js | 8 +++----- locales/en-US.json | 2 +- src/invidious/views/post.ecr | 3 +++ src/invidious/views/watch.ecr | 3 +++ 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/assets/js/comments.js b/assets/js/comments.js index 6c0f7c1d..f948a3f8 100644 --- a/assets/js/comments.js +++ b/assets/js/comments.js @@ -106,8 +106,8 @@ function get_youtube_comments() { } }, onNon200: video_data.params.comments[1] === 'youtube' - ? function (xhr) {} - : function (xhr) { comments.innerHTML = fallback; }, + ? function (xhr) {} + : function (xhr) { comments.innerHTML = (xhr.response.error === 'Comments not found.' ? fallback.split('')[1] : fallback.split('

')[0]) }, onError: function (xhr) { comments.innerHTML = spinnerHTML; }, diff --git a/assets/js/community.js b/assets/js/community.js index 32fe4ebc..9b29bbf2 100644 --- a/assets/js/community.js +++ b/assets/js/community.js @@ -72,7 +72,7 @@ function get_youtube_replies(target, load_more) { } }, onNon200: function (xhr) { - body.innerHTML = fallback; + body.innerHTML = (xhr.response.error === 'Comments not found.' ? fallback.split('')[1] : fallback.split('

')[0]); }, onTimeout: function (xhr) { console.warn('Pulling comments failed'); diff --git a/assets/js/watch.js b/assets/js/watch.js index 26ad138f..736cecb3 100644 --- a/assets/js/watch.js +++ b/assets/js/watch.js @@ -117,10 +117,6 @@ function get_reddit_comments() { '?source=reddit&format=html' + '&hl=' + video_data.preferences.locale; - var onNon200 = function (xhr) { comments.innerHTML = fallback; }; - if (video_data.params.comments[1] === 'youtube') - onNon200 = function (xhr) {}; - helpers.xhr('GET', url, {retries: 5, entity_name: ''}, { on200: function (response) { comments.innerHTML = ' \ @@ -152,7 +148,9 @@ function get_reddit_comments() { comments.children[0].children[0].children[0].onclick = toggle_comments; comments.children[0].children[1].children[0].onclick = swap_comments; }, - onNon200: onNon200, // declared above + onNon200: video_data.params.comments[1] === 'youtube' + ? function (xhr) {} + : function (xhr) { comments.innerHTML = (xhr.response.error === 'Comments not found.' ? fallback.split('')[1] : fallback.split('

')[0]); } }); } diff --git a/locales/en-US.json b/locales/en-US.json index c23f6bc3..b624ce86 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -234,7 +234,7 @@ "Deleted or invalid channel": "Deleted or invalid channel", "This channel does not exist.": "This channel does not exist.", "Could not get channel info.": "Could not get channel info.", - "Could not fetch comments": "Could not fetch comments", + "Could not fetch comments": "Could not fetch comments (they may be turned off)", "comments_view_x_replies": "View {{count}} reply", "comments_view_x_replies_plural": "View {{count}} replies", "`x` ago": "`x` ago", diff --git a/src/invidious/views/post.ecr b/src/invidious/views/post.ecr index fb03a44c..f357999d 100644 --- a/src/invidious/views/post.ecr +++ b/src/invidious/views/post.ecr @@ -21,6 +21,9 @@ <%= translate(locale, "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.") %> +

+ <%= translate(locale, "Could not fetch comments") %> +

<% end %> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 45c58a16..308d0021 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -297,6 +297,9 @@ we're going to need to do it here in order to allow for translations. <%= translate(locale, "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.") %> +

+ <%= translate(locale, "Could not fetch comments") %> +

<% end %>