Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/kanta/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ defmodule Kanta.Cache do
acc <> "_" <> to_string(key) <> "_" <> URI.encode_query(val)

val when is_list(val) ->
acc <> "_" <> to_string(key) <> "_" <> (Enum.into(val, %{}) |> URI.encode_query())
# this old way is just broken for preloads lists
# encoded_list = (Enum.into(val, %{}) |> URI.encode_query())
# the new way is robust and reversible
encoded_list =
val
|> :erlang.term_to_binary()
|> URI.encode()
|> then(&%{encoded_params: &1})
|> URI.encode_query()

acc <> "_" <> to_string(key) <> "_" <> encoded_list

_val ->
acc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ defmodule KantaWeb.Translations.TranslationFormLive do

defp get_message(message_id) do
case parse_id_filter(message_id) do
{:ok, id} -> Translations.get_message(filter: [id: id])
{:ok, id} -> Translations.get_message(filter: [id: id], preloads: [:context])
_ -> {:error, :id, :invalid}
end
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule Kanta.MixProject do
{:ecto_sql, "~> 3.12"},
{:phoenix, "~> 1.7.0"},
{:phoenix_view, "~> 2.0"},
{:phoenix_live_view, "~> 0.20"},
{:phoenix_live_view, ">= 0.20.0"},
{:phoenix_html, "~> 4.0"},
{:phoenix_html_helpers, "~> 1.0"},
{:tailwind, "~> 0.2", runtime: Mix.env() == :dev},
Expand Down