Make the preview_url optional

It won't always be present, especially for media like audio. (I'll fix
audio eventually.)
This commit is contained in:
Ryan Fox 2021-01-10 21:44:48 +00:00
parent 7eb414190a
commit be05f24b52
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
2 changed files with 9 additions and 2 deletions

View File

@ -85,7 +85,7 @@ attachmentDecoder =
|> Pipe.required "type" Decode.string
|> Pipe.required "url" Decode.string
|> Pipe.optional "remote_url" Decode.string ""
|> Pipe.required "preview_url" Decode.string
|> Pipe.optional "preview_url" Decode.string ""
|> Pipe.required "text_url" (Decode.nullable Decode.string)

View File

@ -42,7 +42,14 @@ attachmentPreview context sensitive attachments ({ url, preview_url } as attachm
, onClickWithPreventAndStop <|
ViewerEvent (OpenViewer attachments attachment)
]
[ img [ src preview_url ] [] ]
[ img [ src <|
if preview_url == "" then
url
else
preview_url
]
[]
]
in
li [ class "attachment-entry" ] <|
if nsfw then