diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index 9904b4fc..2263f8e9 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -1,8 +1,12 @@ -<% - locale = env.get("preferences").as(Preferences).locale - dark_mode = env.get("preferences").as(Preferences).dark_mode -%> +<%- + user = env.get?("user").try &.as(IV::User) + prefs = env.get?("preferences").try &.as(Preferences) + + locale = prefs.try &.locale || "en-US" + dark_mode = prefs.try &.dark_mode || "auto" + show_nick = prefs.try &.show_nick || false +-%> @@ -40,7 +44,7 @@ <% end %>
- <% if env.get? "user" %> + <% if user %>
" class="pure-menu-heading" title="<%= translate(locale, "toggle_theme") %>"> <% if dark_mode == "dark" %> @@ -52,7 +56,7 @@
" href="/feed/subscriptions" class="pure-menu-heading"> - <% notification_count = env.get("user").as(Invidious::User).notifications.size %> + <% notification_count = user.try &.notifications.size || 0 %> <% if CONFIG.enable_user_notifications && notification_count > 0 %> <%= notification_count %> <% else %> @@ -65,11 +69,11 @@
- <% if env.get("preferences").as(Preferences).show_nick %> + <%- if show_nick -%>
- <%= HTML.escape(env.get("user").as(Invidious::User).email) %> + <%= HTML.escape(user.try &.email) %>
- <% end %> + <%- end -%>
" method="post"> "> @@ -158,7 +162,7 @@
- <% if env.get? "user" %> + <% if user %>