Replace local maybe_put helpers

This commit is contained in:
2026-06-21 14:30:40 +02:00
parent cd4a01a2c8
commit d3c21247e0
7 changed files with 32 additions and 39 deletions

View File

@@ -693,7 +693,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
wxr_file_path: analysis_state.file_path,
last_analysis_result: report
}
|> maybe_put(:name, AnalysisState.suggested_definition_name(report))
|> BDS.MapUtils.maybe_put(:name, AnalysisState.suggested_definition_name(report))
case ImportDefinitions.update_definition(definition_id, attrs) do
{:ok, _definition} ->
@@ -1453,7 +1453,4 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
defp blank?(value), do: value in [nil, ""]
defp blank_to_nil(""), do: nil
defp blank_to_nil(value), do: value
defp maybe_put(map, _key, nil), do: map
defp maybe_put(map, key, value), do: Map.put(map, key, value)
end

View File

@@ -160,7 +160,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do
wxr_file_path: analysis_state.file_path,
last_analysis_result: report
}
|> maybe_put(:name, suggested_definition_name(report))
|> BDS.MapUtils.maybe_put(:name, suggested_definition_name(report))
case ImportDefinitions.update_definition(definition_id, attrs) do
{:ok, _definition} ->
@@ -274,10 +274,6 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do
get_in(report, [:site_info, :url]) || get_in(report, [:site_info, :title])
end
@spec maybe_put(term(), term(), term()) :: term()
def maybe_put(map, _key, nil), do: map
def maybe_put(map, key, value), do: Map.put(map, key, value)
@spec allow_repo_sandbox(term()) :: term()
def allow_repo_sandbox(pid) when is_pid(pid) do
if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do