forked from potsda.mn/mobilizon
[JSON-LD] Only render single location when list has only one element
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
2eee09bf4b
commit
bfc936f57c
|
@ -176,6 +176,7 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
||||||
[]
|
[]
|
||||||
|> render_location(event)
|
|> render_location(event)
|
||||||
|> render_virtual_location(event)
|
|> render_virtual_location(event)
|
||||||
|
|> maybe_render_single_element()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec render_location(list(), map()) :: list()
|
@spec render_location(list(), map()) :: list()
|
||||||
|
@ -207,6 +208,10 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
||||||
|
|
||||||
defp render_virtual_location(locations, _), do: locations
|
defp render_virtual_location(locations, _), do: locations
|
||||||
|
|
||||||
|
@spec maybe_render_single_element(list(map())) :: list(map()) | map()
|
||||||
|
defp maybe_render_single_element([location]), do: location
|
||||||
|
defp maybe_render_single_element(locations), do: locations
|
||||||
|
|
||||||
defp render_address(%{physical_address: %Address{} = address}),
|
defp render_address(%{physical_address: %Address{} = address}),
|
||||||
do: render_one(address, ObjectView, "address.json", as: :address)
|
do: render_one(address, ObjectView, "address.json", as: :address)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue