From bce79ca2eea3c0aa6993708b32ac1eaab41fb7e7 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:20:41 -0500 Subject: [PATCH 1/3] don't error when a channel doesn't have any community posts --- src/invidious/channels/community.cr | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr index 49ffd990..2cb8bc9a 100644 --- a/src/invidious/channels/community.cr +++ b/src/invidious/channels/community.cr @@ -57,6 +57,17 @@ def extract_channel_community(items, *, ucid, locale, format, thin_mode, is_sing .try &.as_s || "" if error_message == "This channel does not exist." raise NotFoundException.new(error_message) + elsif error_message == "This channel hasn't posted yet" + response = JSON.build do |json| + json.object do + json.field "authorId", ucid + json.field "comments" do + json.array do + end + end + end + end + return response else raise InfoException.new(error_message) end From eafaf4a82a8b75c40fcf54c55d950995364d8e56 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Thu, 15 Feb 2024 19:50:59 -0500 Subject: [PATCH 2/3] Add message for when channel has no posts --- locales/en-US.json | 3 ++- src/invidious/views/community.ecr | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/locales/en-US.json b/locales/en-US.json index 10887612..7347409b 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -496,5 +496,6 @@ "toggle_theme": "Toggle Theme", "carousel_slide": "Slide {{current}} of {{total}}", "carousel_skip": "Skip the Carousel", - "carousel_go_to": "Go to slide `x`" + "carousel_go_to": "Go to slide `x`", + "channel_has_no_posts": "This channel hasn't posted yet" } diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index d2a305d3..b813533c 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -25,6 +25,10 @@

<%= error_message %>

+<% elsif items.not_nil!["comments"].as_a.empty? %> +
+ <%= translate(locale, "channel_has_no_posts") %> +
<% else %>
<%= IV::Frontend::Comments.template_youtube(items.not_nil!, locale, thin_mode) %> From ee9f4e21abea80e09693341580376b6ade6e0666 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Thu, 15 Feb 2024 19:51:35 -0500 Subject: [PATCH 3/3] Simplify creation of empty json array Co-Authored-By: Samantaz Fox --- src/invidious/channels/community.cr | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr index 2cb8bc9a..cd658f34 100644 --- a/src/invidious/channels/community.cr +++ b/src/invidious/channels/community.cr @@ -61,10 +61,7 @@ def extract_channel_community(items, *, ucid, locale, format, thin_mode, is_sing response = JSON.build do |json| json.object do json.field "authorId", ucid - json.field "comments" do - json.array do - end - end + json.field "comments", json.array { } end end return response