fix edit reason offset in version history

This commit is contained in:
byte[] 2021-02-25 14:57:20 -05:00
parent 351cb282bf
commit 2768b5753b

View file

@ -24,22 +24,25 @@ defmodule Philomena.Versions do
{versions, _last_body} =
versions
|> Enum.map_reduce(parent.body, fn version, previous_body ->
yaml = YamlElixir.read_from_string!(version.object || "")
body = yaml["body"] || ""
edit_reason = yaml["edit_reason"]
|> Enum.map_reduce(
{parent.body, parent.edit_reason},
fn version, {previous_body, previous_reason} ->
yaml = YamlElixir.read_from_string!(version.object || "")
body = yaml["body"] || ""
edit_reason = yaml["edit_reason"]
v = %{
version
| parent: parent,
user: users[version.whodunnit],
body: body,
edit_reason: edit_reason,
difference: difference(body, previous_body)
}
v = %{
version
| parent: parent,
user: users[version.whodunnit],
body: body,
edit_reason: previous_reason,
difference: difference(body, previous_body)
}
{v, body}
end)
{v, {body, edit_reason}}
end
)
versions
end