From bc5d8d0b9b778b130f3a91cd154c9c0d469b09ff Mon Sep 17 00:00:00 2001 From: Fijxu Date: Thu, 1 Jan 2026 22:03:17 -0300 Subject: [PATCH] feat: Do not display backends that do not have an i2p equivalent when using i2p --- src/invidious/routes/before_all.cr | 2 ++ src/invidious/views/template.ecr | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/invidious/routes/before_all.cr b/src/invidious/routes/before_all.cr index ca7e26dc..e5aa9482 100644 --- a/src/invidious/routes/before_all.cr +++ b/src/invidious/routes/before_all.cr @@ -85,8 +85,10 @@ module Invidious::Routes::BeforeAll env.set "current_companion", current_companion if host.split(".").last == "i2p" + env.set "using_i2p", true env.set "companion_public_url", CONFIG.invidious_companion[current_companion].i2p_public_url.to_s else + env.set "using_i2p", false env.set "companion_public_url", CONFIG.invidious_companion[current_companion].public_url.to_s end end diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index e1bac53d..1e17462a 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -114,12 +114,14 @@ scheme = env.get("scheme") status = BackendInfo.get_status companion_switched = env.get?("companion_switched") + using_i2p = env.get?("using_i2p") %>
<%= translate(locale, "companion_switch_backend") %> <% if domain %> <% CONFIG.invidious_companion.each_with_index do | companion, index | %> <% next if companion.community && !preferences.show_community_backends %> + <% next if companion.i2p_public_url.host.nil? && using_i2p %> <% host_backend = env.request.headers["Host"].sub(/([^.]+)(\d+)/, "\\1#{index+1}") %> <% is_current_backend_host = host_backend == env.request.headers["Host"] %> display: inline-block;"> @@ -138,6 +140,7 @@ <% current_page = env.get("current_page") %> <% CONFIG.invidious_companion.each_with_index do | companion, index | %> <% next if companion.community && !preferences.show_community_backends %> + <% next if companion.i2p_public_url.host.nil? && using_i2p %> display: inline-block;"> <%= HTML.escape(CONFIG.backend_name_prefix + (index + 1).to_s) %> <%= HTML.escape(companion.note) %>