From be05f24b52083a26656eda6a8b9386a3c1441d2f Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Sun, 10 Jan 2021 21:44:48 +0000 Subject: [PATCH] Make the preview_url optional It won't always be present, especially for media like audio. (I'll fix audio eventually.) --- src/Mastodon/Decoder.elm | 2 +- src/View/Status.elm | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mastodon/Decoder.elm b/src/Mastodon/Decoder.elm index da6de58..27c1568 100644 --- a/src/Mastodon/Decoder.elm +++ b/src/Mastodon/Decoder.elm @@ -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) diff --git a/src/View/Status.elm b/src/View/Status.elm index edfd7d7..c33a7c2 100644 --- a/src/View/Status.elm +++ b/src/View/Status.elm @@ -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