diff --git a/src/Twitch.elm b/src/Twitch.elm index 6823463..17d4fcc 100644 --- a/src/Twitch.elm +++ b/src/Twitch.elm @@ -27,7 +27,7 @@ type alias Video = { name : String , url : String , duration : Int - , date : Time.Posix + , date : Maybe Time.Posix } @@ -152,10 +152,10 @@ parseVideo url result = Ok v _ -> - Ok { name = "", url = url, duration = 0, date = Time.millisToPosix 0 } + Ok { name = "", url = url, duration = 0, date = Nothing } _ -> - Ok { name = "", url = url, duration = 0, date = Time.millisToPosix 0 } + Ok { name = "", url = url, duration = 0, date = Nothing } fetchPlaylistsMapper : List String -> Task x (List Playlist) @@ -247,4 +247,4 @@ decodeVideo url = Decode.map3 (\x y -> Video x url y) (Decode.field "title" Decode.string) (Decode.map Basics.round (Decode.field "duration" Decode.float)) - (Decode.field "date" Iso8601.decoder) + (Decode.nullable (Decode.field "date" Iso8601.decoder)) diff --git a/src/Views.elm b/src/Views.elm index ac9d81a..bdc450e 100644 --- a/src/Views.elm +++ b/src/Views.elm @@ -314,9 +314,14 @@ videoView zone playlist video = , Element.paddingEach { top = 10, left = 0, bottom = 0, right = 0 } ] [ Element.text video.name ] - , Element.paragraph - [ Font.size Consts.titleFontSize ] - [ Element.text ("Diffusé le " ++ formatDate zone video.date) ] + , case video.date of + Just date -> + Element.paragraph + [ Font.size Consts.titleFontSize ] + [ Element.text ("Diffusé le " ++ formatDate zone date) ] + + _ -> + Element.none ] , Element.column [ Element.alignTop, Element.spacing 10, Element.width (Element.fillPortion 1) ] (List.map (videoInList zone playlist video) playlist.videos) @@ -331,10 +336,15 @@ videoDescription zone video = , Font.size Consts.titleFontSize ] [ Element.text video.name ] - , Element.paragraph - [ Font.color Colors.greyFont - ] - [ Element.text ("Diffusé le " ++ formatDate zone video.date) ] + , case video.date of + Just date -> + Element.paragraph + [ Font.color Colors.greyFont + ] + [ Element.text ("Diffusé le " ++ formatDate zone date) ] + + _ -> + Element.none ]