Skip to content

Commit

Permalink
Don't nest YouTube replies
Browse files Browse the repository at this point in the history
  • Loading branch information
omarroth committed Oct 22, 2018
1 parent ed3d9ce commit 81ea2bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/invidious/comments.cr
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def template_youtube_comments(comments)
<div class="pure-u-1">
<p>
<a href="javascript:void(0)" data-continuation="#{comments["continuation"]}"
onclick="get_youtube_replies(this)">Load more</a>
onclick="get_youtube_replies(this, true)">Load more</a>
</p>
</div>
</div>
Expand Down
22 changes: 14 additions & 8 deletions src/invidious/views/watch.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function get_youtube_comments() {
};
}
function get_youtube_replies(target) {
function get_youtube_replies(target, load_more) {
var continuation = target.getAttribute('data-continuation');
var body = target.parentNode.parentNode;
Expand All @@ -398,13 +398,19 @@ function get_youtube_replies(target) {
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
body.innerHTML = ' \
<p><a href="javascript:void(0)" \
onclick="hide_youtube_replies(this)">Hide replies \
</a></p> \
<div>{contentHtml}</div>'.supplant({
contentHtml: xhr.response.contentHtml,
});
if (load_more) {
body = body.parentNode.parentNode;
body.removeChild(body.lastElementChild);
body.innerHTML += xhr.response.contentHtml;
} else {
body.innerHTML = ' \
<p><a href="javascript:void(0)" \
onclick="hide_youtube_replies(this)">Hide replies \
</a></p> \
<div>{contentHtml}</div>'.supplant({
contentHtml: xhr.response.contentHtml,
});
}
} else {
body.innerHTML = fallback;
}
Expand Down

0 comments on commit 81ea2bf

Please sign in to comment.