actually use the Data import

This commit is contained in:
Aaron Bieber 2023-04-23 19:24:30 -06:00
parent 4ad5b2964a
commit 69246c500c
No known key found for this signature in database

View File

@ -1,6 +1,7 @@
module Main exposing (..) module Main exposing (..)
import Browser import Browser
import Data
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (style) import Html.Attributes exposing (style)
import Html.Events exposing (..) import Html.Events exposing (..)
@ -20,40 +21,7 @@ main =
type Model type Model
= Failure = Failure
| Loading | Loading
| Success (List Watch) | Success (List Data.Watch)
type alias Watch =
{ owner_id : Int
, name : String
, repo : String
, result_count : Int
}
type alias Node =
{ number : Int
}
type alias Edge =
{ node : Node
}
type alias WatchData =
{ search : List Edge
}
type alias Link =
{ id : Int
, owner_id : Int
, created_at : String
, name : String
, url : String
, logo_url : String
}
init : () -> ( Model, Cmd Msg ) init : () -> ( Model, Cmd Msg )
@ -67,7 +35,7 @@ init _ =
type Msg type Msg
= MorePlease = MorePlease
| GetWatches (Result Http.Error (List Watch)) | GetWatches (Result Http.Error (List Data.Watch))
update : Msg -> Model -> ( Model, Cmd Msg ) update : Msg -> Model -> ( Model, Cmd Msg )
@ -139,21 +107,21 @@ getWatches =
} }
watchListDecoder : Decoder (List Watch) watchListDecoder : Decoder (List Data.Watch)
watchListDecoder = watchListDecoder =
list watchDecoder list watchDecoder
watchDecoder : Decoder Watch watchDecoder : Decoder Data.Watch
watchDecoder = watchDecoder =
map4 Watch map4 Data.Watch
(field "owner_id" int) (field "owner_id" int)
(field "name" string) (field "name" string)
(field "repo" string) (field "repo" string)
(field "result_count" int) (field "result_count" int)
viewWatch : Watch -> Html Msg viewWatch : Data.Watch -> Html Msg
viewWatch watch = viewWatch watch =
li [] li []
[ text (String.fromInt watch.result_count ++ " " ++ watch.name) [ text (String.fromInt watch.result_count ++ " " ++ watch.name)