From 385d9d242a74029240849a9b066c6f80152b3583 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Thu, 8 Feb 2018 16:33:08 -0500 Subject: [PATCH] Clean up code and remove unused dependencies --- elm-package.json | 1 - src/Paginated.elm | 10 ++-------- src/Paginated/Util.elm | 10 ++++++---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/elm-package.json b/elm-package.json index ce6a049..462f681 100644 --- a/elm-package.json +++ b/elm-package.json @@ -12,7 +12,6 @@ "dependencies": { "elm-community/maybe-extra": "4.0.0 <= v < 5.0.0", "elm-lang/core": "5.1.1 <= v < 6.0.0", - "elm-lang/html": "2.0.0 <= v < 3.0.0", "elm-lang/http": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.18.0 <= v < 0.19.0" diff --git a/src/Paginated.elm b/src/Paginated.elm index 458069b..6297db5 100644 --- a/src/Paginated.elm +++ b/src/Paginated.elm @@ -37,7 +37,6 @@ import Char import Dict exposing (Dict) import Http import Json.Decode exposing (Decoder) -import Maybe.Extra import Paginated.Util import Task exposing (Task) import Time @@ -130,7 +129,7 @@ send : -> Request a -> Cmd msg send resultToMessage request = - toTask request + toTask request |> Task.attempt resultToMessage @@ -214,18 +213,13 @@ fromResponse options response = (Json.Decode.list options.decoder) response.body - normalize : Dict String String -> Dict String String - normalize = - Dict.toList - >> Dict.fromList - nextPage : Maybe String nextPage = header "Link" response.headers |> Maybe.map Paginated.Util.links |> Maybe.andThen (Dict.get "next") in - case Debug.log "nextPage" nextPage of + case nextPage of Nothing -> Result.map Complete items diff --git a/src/Paginated/Util.elm b/src/Paginated/Util.elm index e576681..73e3396 100644 --- a/src/Paginated/Util.elm +++ b/src/Paginated/Util.elm @@ -25,11 +25,13 @@ links s = _ -> Nothing in - Regex.find - Regex.All - (Regex.regex "<(.*?)>; rel=\"(.*?)\"") - s + Regex.find Regex.All linkPattern s |> List.map .submatches |> List.map toTuples |> Maybe.Extra.values |> Dict.fromList + + +linkPattern : Regex.Regex +linkPattern = + Regex.regex "<(.*?)>; rel=\"(.*?)\""