From 3ffebd15332c7c20a6b02674f5cf6cfbdbe0da4d Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 8 Apr 2024 12:46:54 -0400 Subject: [PATCH] Fix dynamic typing mistake --- lib/philomena_web/templates/search/index.html.slime | 2 +- lib/philomena_web/views/search_view.ex | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/philomena_web/templates/search/index.html.slime b/lib/philomena_web/templates/search/index.html.slime index 878d24861..2c4cffe98 100644 --- a/lib/philomena_web/templates/search/index.html.slime +++ b/lib/philomena_web/templates/search/index.html.slime @@ -1,5 +1,5 @@ = cond do - - Enum.any?(@images) or Enum.any?(@tags, &Enum.any?(elem(&1, 0).dnp_entries)) -> + - Enum.any?(@images) or override_display(@tags) -> = render PhilomenaWeb.ImageView, "index.html", conn: @conn, tags: @tags, images: @images, header: "Searching for #{@conn.params["q"]}", route: fn p -> Routes.search_path(@conn, :index, p) end, scope: scope(@conn) - assigns[:error] -> diff --git a/lib/philomena_web/views/search_view.ex b/lib/philomena_web/views/search_view.ex index 8500d4d83..d03b689c3 100644 --- a/lib/philomena_web/views/search_view.ex +++ b/lib/philomena_web/views/search_view.ex @@ -3,4 +3,10 @@ defmodule PhilomenaWeb.SearchView do def scope(conn), do: PhilomenaWeb.ImageScope.scope(conn) def hides_images?(conn), do: can?(conn, :hide, %Philomena.Images.Image{}) + + def override_display([{_tag, _description, dnp_entries}]) do + Enum.any?(dnp_entries) + end + + def override_display(_), do: false end