From f86e907317ec81a766ea21c9203e4cd6b06c10fe Mon Sep 17 00:00:00 2001 From: Tessa Kelly Date: Mon, 8 Apr 2019 17:07:46 -0700 Subject: [PATCH] :art: tidy up the summarization logic --- src/Nri/Ui/SlideModal/V1.elm | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/Nri/Ui/SlideModal/V1.elm b/src/Nri/Ui/SlideModal/V1.elm index 81456562..5a03aae3 100644 --- a/src/Nri/Ui/SlideModal/V1.elm +++ b/src/Nri/Ui/SlideModal/V1.elm @@ -95,28 +95,16 @@ summarize (State state) panels = in case state of Just current -> - case List.drop (current - 1) panels of - first :: second :: rest -> - if current > 0 then - Just - { current = second - , previousPanel = Just first - , upcoming = List.drop (current + 1) indexedPanels - , previous = List.take current indexedPanels - } - - else - Just - { current = first - , previousPanel = Nothing - , upcoming = List.drop (current + 1) indexedPanels - , previous = List.take current indexedPanels - } - - first :: [] -> + case List.drop current panels of + currentPanel :: rest -> Just - { current = first - , previousPanel = Nothing + { current = currentPanel + , previousPanel = + if current > 0 then + List.head (List.drop (current - 1) panels) + + else + Nothing , upcoming = List.drop (current + 1) indexedPanels , previous = List.take current indexedPanels }