Skip to content

Commit

Permalink
peek back instead of reconstructing all of history
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Sep 25, 2020
1 parent e2a5b7f commit 9f68d32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/History.elm
@@ -1,4 +1,4 @@
module History exposing (History, current, goBack, init, mapPush, push)
module History exposing (History, current, goBack, init, mapPush, peekBack, push)

{-| -}

Expand Down Expand Up @@ -45,6 +45,11 @@ mapPush fn history =
push (fn (current history)) history


peekBack : History a -> Maybe a
peekBack (History guts) =
List.head guts.past


goBack : History a -> Maybe (History a)
goBack (History guts) =
case guts.past of
Expand Down
3 changes: 1 addition & 2 deletions src/Main.elm
Expand Up @@ -377,8 +377,7 @@ rankings : Model -> Html Msg
rankings model =
let
previousStandings =
History.goBack model.history
|> Maybe.map History.current
History.peekBack model.history
|> Maybe.withDefault (History.current model.history)
|> League.players
|> List.sortBy (\player -> -player.rating)
Expand Down

0 comments on commit 9f68d32

Please sign in to comment.