mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
fixes #116: hidden images appear in navigation
This commit is contained in:
parent
84d784d33a
commit
a656f64225
2 changed files with 7 additions and 3 deletions
|
@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.NavigateController do
|
||||||
filter = conn.assigns.compiled_filter
|
filter = conn.assigns.compiled_filter
|
||||||
rel = String.to_existing_atom(rel)
|
rel = String.to_existing_atom(rel)
|
||||||
|
|
||||||
next_image = ImageNavigator.find_consecutive(image, rel, params, compile_query(conn), filter)
|
next_image = ImageNavigator.find_consecutive(conn, image, rel, params, compile_query(conn), filter)
|
||||||
scope = ImageScope.scope(conn)
|
scope = ImageScope.scope(conn)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -24,7 +24,7 @@ defmodule PhilomenaWeb.ImageNavigator do
|
||||||
lt: :lte
|
lt: :lte
|
||||||
}
|
}
|
||||||
|
|
||||||
def find_consecutive(image, rel, params, compiled_query, compiled_filter) do
|
def find_consecutive(conn, image, rel, params, compiled_query, compiled_filter) do
|
||||||
image_index =
|
image_index =
|
||||||
Image
|
Image
|
||||||
|> where(id: ^image.id)
|
|> where(id: ^image.id)
|
||||||
|
@ -51,7 +51,8 @@ defmodule PhilomenaWeb.ImageNavigator do
|
||||||
must: List.flatten([compiled_query, sort_data.queries, filters]),
|
must: List.flatten([compiled_query, sort_data.queries, filters]),
|
||||||
must_not: [
|
must_not: [
|
||||||
compiled_filter,
|
compiled_filter,
|
||||||
%{term: %{hidden_from_users: true}}
|
%{term: %{hidden_from_users: true}},
|
||||||
|
hidden_filter(conn.assigns.current_user, conn.params["hidden"])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -135,6 +136,9 @@ defmodule PhilomenaWeb.ImageNavigator do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp hidden_filter(%{id: id}, param) when param != "1", do: %{term: %{hidden_by_user_ids: id}}
|
||||||
|
defp hidden_filter(_user, _param), do: %{match_none: %{}}
|
||||||
|
|
||||||
defp range_filter(sf, dir, val) do
|
defp range_filter(sf, dir, val) do
|
||||||
%{
|
%{
|
||||||
this: %{range: %{sf => %{dir => parse_val(val)}}},
|
this: %{range: %{sf => %{dir => parse_val(val)}}},
|
||||||
|
|
Loading…
Reference in a new issue