forked from AkkomaGang/akkoma
Extract if block into private function
This commit is contained in:
parent
cc84563796
commit
c5338764df
1 changed files with 10 additions and 5 deletions
|
@ -119,6 +119,14 @@ defp add_if_present(
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp normalize_fields_attributes(fields) do
|
||||||
|
if Enum.all?(fields, &is_tuple/1) do
|
||||||
|
Enum.map(fields, fn {_, v} -> v end)
|
||||||
|
else
|
||||||
|
fields
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update_credentials(%{assigns: %{user: user}} = conn, params) do
|
def update_credentials(%{assigns: %{user: user}} = conn, params) do
|
||||||
original_user = user
|
original_user = user
|
||||||
|
|
||||||
|
@ -146,11 +154,8 @@ def update_credentials(%{assigns: %{user: user}} = conn, params) do
|
||||||
params =
|
params =
|
||||||
if Map.has_key?(params, "fields_attributes") do
|
if Map.has_key?(params, "fields_attributes") do
|
||||||
Map.update!(params, "fields_attributes", fn fields ->
|
Map.update!(params, "fields_attributes", fn fields ->
|
||||||
if Enum.all?(fields, &is_tuple/1) do
|
|
||||||
Enum.map(fields, fn {_, v} -> v end)
|
|
||||||
else
|
|
||||||
fields
|
fields
|
||||||
end
|
|> normalize_fields_attributes()
|
||||||
|> Enum.filter(fn %{"name" => n} -> n != "" end)
|
|> Enum.filter(fn %{"name" => n} -> n != "" end)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue