mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fix navigation between images being borked
This commit is contained in:
parent
b6248e22ee
commit
317a568521
2 changed files with 7 additions and 0 deletions
|
@ -9,6 +9,8 @@ defmodule PhilomenaWeb.ImageNavigator do
|
||||||
}
|
}
|
||||||
|
|
||||||
def find_consecutive(conn, image, compiled_query, compiled_filter) do
|
def find_consecutive(conn, image, compiled_query, compiled_filter) do
|
||||||
|
conn = update_in(conn.params, &Map.put_new(&1, "sf", "id"))
|
||||||
|
|
||||||
%{query: compiled_query, sorts: sorts} = ImageSorter.parse_sort(conn.params, compiled_query)
|
%{query: compiled_query, sorts: sorts} = ImageSorter.parse_sort(conn.params, compiled_query)
|
||||||
|
|
||||||
sorts =
|
sorts =
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
defmodule PhilomenaWeb.ImageSorter do
|
defmodule PhilomenaWeb.ImageSorter do
|
||||||
@allowed_fields ~W(
|
@allowed_fields ~W(
|
||||||
|
id
|
||||||
updated_at
|
updated_at
|
||||||
first_seen_at
|
first_seen_at
|
||||||
aspect_ratio
|
aspect_ratio
|
||||||
|
@ -26,6 +27,10 @@ defmodule PhilomenaWeb.ImageSorter do
|
||||||
defp parse_sd(%{"sd" => sd}) when sd in ~W(asc desc), do: sd
|
defp parse_sd(%{"sd" => sd}) when sd in ~W(asc desc), do: sd
|
||||||
defp parse_sd(_params), do: "desc"
|
defp parse_sd(_params), do: "desc"
|
||||||
|
|
||||||
|
defp parse_sf(%{"sf" => sf}, sd, query) when sf == "id" do
|
||||||
|
%{query: query, sorts: [%{"id" => sd}]}
|
||||||
|
end
|
||||||
|
|
||||||
defp parse_sf(%{"sf" => sf}, sd, query) when sf in @allowed_fields do
|
defp parse_sf(%{"sf" => sf}, sd, query) when sf in @allowed_fields do
|
||||||
%{query: query, sorts: [%{sf => sd}, %{"id" => sd}]}
|
%{query: query, sorts: [%{sf => sd}, %{"id" => sd}]}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue