From 24526096ba9b79a479abcfccbdd68e3ee0e2f531 Mon Sep 17 00:00:00 2001 From: James Gough Date: Mon, 18 Nov 2024 17:26:12 +0000 Subject: [PATCH 1/4] encode better --- lib/kanta/cache.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/kanta/cache.ex b/lib/kanta/cache.ex index 26d5a5d..4816813 100644 --- a/lib/kanta/cache.ex +++ b/lib/kanta/cache.ex @@ -15,7 +15,11 @@ 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 From 4a94cb4d93d6817e1a1a5dd6854e770785b78508 Mon Sep 17 00:00:00 2001 From: James Gough Date: Mon, 18 Nov 2024 17:26:20 +0000 Subject: [PATCH 2/4] preload context on messages in single trans --- .../translations/translation_form_live/translation_form_live.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kanta_web/live/translations/translation_form_live/translation_form_live.ex b/lib/kanta_web/live/translations/translation_form_live/translation_form_live.ex index 9cd9a45..e337943 100644 --- a/lib/kanta_web/live/translations/translation_form_live/translation_form_live.ex +++ b/lib/kanta_web/live/translations/translation_form_live/translation_form_live.ex @@ -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 From ab3626809c978aa604ba4e81141186e173dde171 Mon Sep 17 00:00:00 2001 From: James Gough Date: Mon, 18 Nov 2024 17:42:53 +0000 Subject: [PATCH 3/4] mix format --- lib/kanta/cache.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/kanta/cache.ex b/lib/kanta/cache.ex index 4816813..d068058 100644 --- a/lib/kanta/cache.ex +++ b/lib/kanta/cache.ex @@ -18,7 +18,13 @@ defmodule Kanta.Cache do # 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() + encoded_list = + val + |> :erlang.term_to_binary() + |> URI.encode() + |> then(&%{encoded_params: &1}) + |> URI.encode_query() + acc <> "_" <> to_string(key) <> "_" <> encoded_list _val -> From 14698bc986d555b241855a200f1557c6aba92ce9 Mon Sep 17 00:00:00 2001 From: James Gough Date: Mon, 23 Dec 2024 11:24:14 +0000 Subject: [PATCH 4/4] make lv version more lenient --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index d8d966b..7a6f04c 100644 --- a/mix.exs +++ b/mix.exs @@ -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},