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,7 +24,9 @@ defmodule Philomena.Versions do
{versions, _last_body} =
versions
|> Enum.map_reduce(parent.body, fn version, previous_body ->
|> 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"]
@ -34,12 +36,13 @@ defmodule Philomena.Versions do
| parent: parent,
user: users[version.whodunnit],
body: body,
edit_reason: edit_reason,
edit_reason: previous_reason,
difference: difference(body, previous_body)
}
{v, body}
end)
{v, {body, edit_reason}}
end
)
versions
end