From a24ee62d16995ef2a524426173bfd5c035672387 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 15 Nov 2024 11:02:06 +0100 Subject: [PATCH] Split mode functions into raw and rendered If we want to create different html to the default the raw functions can be used to build html from the reply itself. --- src/main/dda/masto_embed/modes.cljs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/dda/masto_embed/modes.cljs b/src/main/dda/masto_embed/modes.cljs index d1b5ed7..294e1eb 100644 --- a/src/main/dda/masto_embed/modes.cljs +++ b/src/main/dda/masto_embed/modes.cljs @@ -61,7 +61,7 @@ first))) out)) -(defn replies-mode [host-url account-name post-id filter-favorited] +(defn replies-mode-raw [host-url account-name post-id filter-favorited] (go (let [replies (-> (> combined (filter #(or (not filter-favorited) (:favorited %))) (reverse) - (map :status) - (th/masto->html "replies-mode") - (render-html) - (b/render-to-document))))) + (map :status))))) -(defn account-mode [host-url account-name] +(defn replies-mode [host-url account-name post-id filter-favorited] + (go + (->> (replies-mode-raw host-url account-name post-id filter-favorited) + (th/masto->html "replies-mode") + (render-html) + (b/render-to-document)))) + +(defn account-mode-raw [host-url account-name] (go (let [account-id ( @@ -85,7 +89,11 @@ (->> status (filter #(= nil (:reblog %))) (filter #(= nil (:in_reply_to_account_id %))) - (take 4) - (th/masto->html "account-mode") - (render-html) - (b/render-to-document))))) + (take 4))))) + +(defn account-mode [host-url account-name] + (go + (->> (account-mode-raw host-url account-name) + (th/masto->html "account-mode") + (render-html) + (b/render-to-document))))