From 160eacf313712a94be243466f1e4f4f5ac94f1e2 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 10 Mar 2022 10:18:37 +0100 Subject: [PATCH] refactored code into reply and account mode --- public/index.html | 4 ++- src/main/dda/masto_embed/app.cljs | 52 ++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/public/index.html b/public/index.html index bd33162..40a5327 100644 --- a/public/index.html +++ b/public/index.html @@ -10,7 +10,9 @@
+ host_url="https://social.meissa-gmbh.de" + replies_to="107779492679907372" + filter_favorited=true> Here the timeline will appear.
diff --git a/src/main/dda/masto_embed/app.cljs b/src/main/dda/masto_embed/app.cljs index f0cf6fb..968212f 100644 --- a/src/main/dda/masto_embed/app.cljs +++ b/src/main/dda/masto_embed/app.cljs @@ -39,6 +39,12 @@ (defn account-id-from-document [] (element-from-document-by-name "account_id")) +(defn replies-to-from-document [] + (element-from-document-by-name "replies_to")) + +(defn filter-favorited-from-document [] + (element-from-document-by-name "filter_favorited")) + (defn render-to-document [input] (-> js/document @@ -83,32 +89,42 @@ (conj result ( (edn) - test-status (-> - (edn)] + (->> statuus + (take 4) + (rb/masto->html) + (render-html) + (render-to-document))))) + +(defn replies-mode [host-url account-name post-id filter-favorited] + (go + (let [test-status (-> + (edn) - favorited (> statuus - ; (take 4) - ; (rb/masto->html) - ; (render-html) - ; (render-to-document)) - (->> filtered + statuus (if filter-favorited filtered test-status)] + (->> statuus (infra/debug) (rb/masto->html) (render-html) - (render-to-document)) - ))) \ No newline at end of file + (render-to-document))))) + +(defn init [] + (let [host-url (host-url-from-document) + account-name (account-name-from-document) + replies-to (replies-to-from-document) + filter-favorited (filter-favorited-from-document) + ] + (if (nil? replies-to) + (account-mode host-url account-name) + (replies-mode host-url account-name replies-to filter-favorited)) + )) \ No newline at end of file