Fix: load() on video select + telm-format
parent
f9cfc28ded
commit
7b1ee76d48
@ -1,4 +1,5 @@
|
||||
elm-stuff
|
||||
repl-temp-*
|
||||
public/application.js
|
||||
public/videos.json
|
||||
public/videos.json
|
||||
public/videos/
|
@ -1,10 +1,10 @@
|
||||
module Msg exposing (..)
|
||||
|
||||
import Http
|
||||
|
||||
import Video
|
||||
|
||||
|
||||
type Msg
|
||||
= NoOp
|
||||
| VideoSelected String
|
||||
| VideoListLanded (Result Http.Error (List Video.Video))
|
||||
= NoOp
|
||||
| VideoSelected String
|
||||
| VideoListLanded (Result Http.Error (List Video.Video))
|
||||
|
@ -1,9 +1,10 @@
|
||||
module Request exposing (..)
|
||||
|
||||
import Http
|
||||
|
||||
import Msg
|
||||
import Video
|
||||
|
||||
|
||||
videoList : Cmd Msg.Msg
|
||||
videoList = Http.get { url = "videos.json", expect = Http.expectJson Msg.VideoListLanded Video.videoListDecoder }
|
||||
videoList =
|
||||
Http.get { url = "videos.json", expect = Http.expectJson Msg.VideoListLanded Video.videoListDecoder }
|
||||
|
@ -1,14 +1,25 @@
|
||||
module Update exposing (..)
|
||||
port module Update exposing (..)
|
||||
|
||||
import Msg
|
||||
import Types
|
||||
|
||||
|
||||
update : Msg.Msg -> Types.Model -> ( Types.Model, Cmd Msg.Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
Msg.VideoSelected path -> ({model | selected = Just path}, Cmd.none)
|
||||
Msg.VideoListLanded response ->
|
||||
case response of
|
||||
Ok videos -> ({model | videos = videos}, Cmd.none)
|
||||
Err _ -> (model, Cmd.none)
|
||||
Msg.NoOp -> (model, Cmd.none)
|
||||
case msg of
|
||||
Msg.VideoSelected path ->
|
||||
( { model | selected = Just path }, reloadVideoSource () )
|
||||
|
||||
Msg.VideoListLanded response ->
|
||||
case response of
|
||||
Ok videos ->
|
||||
( { model | videos = videos }, Cmd.none )
|
||||
|
||||
Err _ ->
|
||||
( model, Cmd.none )
|
||||
|
||||
Msg.NoOp ->
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
port reloadVideoSource : () -> Cmd msg
|
||||
|
Loading…
Reference in New Issue