From a7ac9fab94d427a4569b03420bc47cfee7ae5131 Mon Sep 17 00:00:00 2001 From: Clemens Date: Wed, 29 May 2024 10:12:43 +0200 Subject: [PATCH] do not show link-preview if card is empty --- src/main/dda/masto_embed/to_html.cljs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/dda/masto_embed/to_html.cljs b/src/main/dda/masto_embed/to_html.cljs index 9571913..8aa4d52 100644 --- a/src/main/dda/masto_embed/to_html.cljs +++ b/src/main/dda/masto_embed/to_html.cljs @@ -83,12 +83,14 @@ (defn masto-link-prev->html [html card] (let [{:keys [url image title description]} card] - (-> html - (insert-link-prev) - (cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_URL" url) - (cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_IMG_URL" image) - (cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_TITLE" title) - (cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_DESC" description)))) + (if (nil? card) + html + (-> html + (insert-link-prev) + (cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_URL" url) + (cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_IMG_URL" image) + (cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_TITLE" title) + (cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_DESC" description))))) (defn masto-footer->html [html replies_count reblogs_count favourites_count] (-> html @@ -99,7 +101,8 @@ (defn masto->html [statuses] (let [html (b/post-html-hiccup)] (map (fn [status] - (let [{:keys [account created_at content media_attachments replies_count reblogs_count favourites_count card url]} status] + (let [{:keys [account created_at content media_attachments replies_count reblogs_count favourites_count card url]} status + abc (js/console.log "CARD: " card)] (-> html (masto-header->html account created_at url) (masto-content->html content)