Incorporate unused "unable to load comments" message

This commit is contained in:
Samuel Casellas 2025-01-10 12:47:00 -05:00
parent e64442a373
commit 5451391502
6 changed files with 13 additions and 9 deletions

View File

@ -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('</noscript>')[1] : fallback.split('<p>')[0]) },
onError: function (xhr) {
comments.innerHTML = spinnerHTML;
},

View File

@ -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('</noscript>')[1] : fallback.split('<p>')[0]);
},
onTimeout: function (xhr) {
console.warn('Pulling comments failed');

View File

@ -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('</noscript>')[1] : fallback.split('<p>')[0]); }
});
}

View File

@ -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",

View File

@ -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.") %>
</a>
</noscript>
<p>
<%= translate(locale, "Could not fetch comments") %>
</p>
<% end %>
</div>
</div>

View File

@ -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.") %>
</a>
</noscript>
<p>
<%= translate(locale, "Could not fetch comments") %>
</p>
<% end %>
</div>
</div>