Created
January 6, 2018 13:25
-
-
Save grrinchas/c121904955bca378740a8ee9db1119cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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