refactor(member-live): modularize the overview and drop the superseded in-memory paths

Extract the cookie parser, export-payload builder and fee-status helper
into their own modules and remove the filter/sort/load helpers the
database pushdown made dead, so the overview LiveView stays a thin
coordinator over focused units.
This commit is contained in:
Simon 2026-07-06 10:54:09 +02:00
parent c2cb3edab8
commit 77fc11a0b0
17 changed files with 375 additions and 875 deletions

View file

@ -21,6 +21,8 @@ defmodule MvWeb.MemberLive.Index.ViewSettings do
cookie is read directly from the request conn.
"""
alias MvWeb.MemberLive.Index.Cookie
@cookie_name "member_view_settings"
@session_key "member_view_settings"
@connect_param "view_settings"
@ -117,7 +119,7 @@ defmodule MvWeb.MemberLive.Index.ViewSettings do
case Plug.Conn.get_req_header(conn, "cookie") do
[cookie_header | _rest] ->
cookie_header
|> parse_cookie_header()
|> Cookie.parse_header()
|> Map.get(@cookie_name)
|> parse_json()
@ -170,17 +172,4 @@ defmodule MvWeb.MemberLive.Index.ViewSettings do
end
defp parse_json(_), do: %{}
# Parses a cookie header string into a name => value map.
defp parse_cookie_header(cookie_header) when is_binary(cookie_header) do
cookie_header
|> String.split(";")
|> Enum.map(&String.trim/1)
|> Enum.map(&String.split(&1, "=", parts: 2))
|> Enum.reduce(%{}, fn
[key, value], acc -> Map.put(acc, key, URI.decode(value))
[key], acc -> Map.put(acc, key, "")
_, acc -> acc
end)
end
end