Skip to content

Commit

Permalink
Added another condition for screens that are updated but have the sam…
Browse files Browse the repository at this point in the history
…e ID.
  • Loading branch information
cmaddox5 committed Apr 25, 2024
1 parent ee0a66e commit a192eb0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/screenplay/config/permanent_config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,24 @@ defmodule Screenplay.Config.PermanentConfig do
new_screens ++ updated_pending_screens
end)
|> Enum.reduce({[], [], []}, fn screen,
{new_screen_ids, changed_screen_ids, deleted_screen_ids} ->
{new_screen_ids, changed_screen_ids, deleted_screen_ids} =
acc ->
cond do
screen["is_deleted"] ->
{new_screen_ids, changed_screen_ids, [screen["screen_id"] | deleted_screen_ids]}

# new screen
screen["new_id"] != nil and screen["screen_id"] == nil ->
{[screen["new_id"] | new_screen_ids], changed_screen_ids, deleted_screen_ids}

# screen is existing but had its ID changed.
true ->
{[screen["new_id"] | new_screen_ids], [screen | changed_screen_ids],
screen["new_id"] != nil and screen["screen_id"] != nil ->
{[screen["new_id"] | new_screen_ids], [screen["screen_id"] | changed_screen_ids],
deleted_screen_ids}

# existing screen is being updated but did not change IDs
true ->
acc
end
end)

Expand Down

0 comments on commit a192eb0

Please sign in to comment.