refactor: simplify the code with maps:map/2

Thanks @thalesmg for the suggestion
This commit is contained in:
Kjell Winblad 2024-05-22 18:03:43 +02:00
parent 4b540e3bd0
commit 88c96e26de
1 changed files with 4 additions and 7 deletions

View File

@ -1499,14 +1499,11 @@ maybe_reply(Actions, From, Reply) ->
-spec data_record_to_external_map(data()) -> resource_data().
data_record_to_external_map(Data) ->
AddedChannelsList = maps:to_list(Data#data.added_channels),
AddedChannelsListWithoutConfigs =
[
{ChanID, maps:remove(config, Status)}
|| {ChanID, Status} <- AddedChannelsList
],
AddedChannelsWithoutConfigs =
maps:from_list(AddedChannelsListWithoutConfigs),
maps:map(
fun(_ChanID, Status) -> maps:remove(config, Status) end,
Data#data.added_channels
),
#{
id => Data#data.id,
error => external_error(Data#data.error),