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:
parent
c2cb3edab8
commit
77fc11a0b0
17 changed files with 375 additions and 875 deletions
28
lib/mv_web/live/member_live/index/cookie.ex
Normal file
28
lib/mv_web/live/member_live/index/cookie.ex
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
defmodule MvWeb.MemberLive.Index.Cookie do
|
||||
@moduledoc """
|
||||
Shared cookie-header parsing for the member-overview persistence chain.
|
||||
|
||||
Both `MvWeb.MemberLive.Index.ViewSettings` and
|
||||
`MvWeb.MemberLive.Index.FieldSelection` read their persisted value from the
|
||||
raw request `Cookie:` header on the disconnected mount, so the parsing lives
|
||||
here once.
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Parses a raw `Cookie:` request-header string into a `%{name => value}` map,
|
||||
URL-decoding each value. A valueless entry (`"key"`) maps to `""`; malformed
|
||||
segments are skipped.
|
||||
"""
|
||||
@spec parse_header(String.t()) :: %{String.t() => String.t()}
|
||||
def parse_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
|
||||
Loading…
Add table
Add a link
Reference in a new issue