Accept no date

This commit is contained in:
Thomas Forgione 2020-10-04 18:16:15 +02:00
parent d26dacc40f
commit 383dd93637
2 changed files with 21 additions and 11 deletions

View File

@ -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))

View File

@ -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
]