Skip to content

Instantly share code, notes, and snippets.

@grrinchas
Created January 6, 2018 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grrinchas/c121904955bca378740a8ee9db1119cc to your computer and use it in GitHub Desktop.
Save grrinchas/c121904955bca378740a8ee9db1119cc to your computer and use it in GitHub Desktop.
landing : Model -> Html Msg
landing model =
case model.posts of
NotAsked ->
div [] []
Loading ->
withLoader (div [] [])
Success posts ->
RemoteData.map userHeader model.user
|> RemoteData.withDefault authHeader
|> flip layout (landingBody posts)
Failure err -> error err
readPost : String -> Model -> Html Msg
readPost id model =
case model.posts of
NotAsked ->
div [] []
Loading ->
withLoader (div [] [])
Success posts ->
case List.head <| List.filter (\post -> post.id == id) posts of
Just post ->
RemoteData.map userHeader model.user
|> RemoteData.withDefault authHeader
|> flip layout (readPostBody post)
Nothing ->
error "404 Not Found"
Failure err -> error err
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment