From 85ef9b8667b12be4d8ef819df5309af7f459fa83 Mon Sep 17 00:00:00 2001 From: jem Date: Fri, 19 Jun 2020 11:05:45 +0200 Subject: [PATCH] jans-mob --- public/index.html | 4 ++- shadow-cljs.edn | 2 +- src/main/dda/masto_embed/api.cljs | 13 ++++++--- src/main/dda/masto_embed/app.cljs | 44 +++++++++++++++++++++++++++---- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index 798c377..7f74af7 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,9 @@ masto-embed -
Here the timeline will appear.
diff --git a/shadow-cljs.edn b/shadow-cljs.edn index c040ea1..a581fd1 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -5,7 +5,7 @@ "src/test"] :dependencies - [[orchestra "2018.12.06-2"]] + [[orchestra "2019.02.06-1"]] :dev-http {8080 "public"} :builds {:test diff --git a/src/main/dda/masto_embed/api.cljs b/src/main/dda/masto_embed/api.cljs index d775cf6..d98f8e8 100644 --- a/src/main/dda/masto_embed/api.cljs +++ b/src/main/dda/masto_embed/api.cljs @@ -58,6 +58,13 @@ (str "directory?local=true") #js {}) #(let [response (-> % .-data js->edn)] - (if-let [error (:error response)] - (exit-with-error error) - (callback response))))) + (callback response)))) + +(defn-spec get-directory2 any? + [host-url ::host-url] + (go (let [result ( result + .-data + js->edn)))) diff --git a/src/main/dda/masto_embed/app.cljs b/src/main/dda/masto_embed/app.cljs index 648abf2..7c1a531 100644 --- a/src/main/dda/masto_embed/app.cljs +++ b/src/main/dda/masto_embed/app.cljs @@ -16,6 +16,8 @@ (ns dda.masto-embed.app (:require [dda.masto-embed.api :as api] + [cljs.core.async :refer [go close! put! take! timeout chan !]] + [cljs.core.async.interop :refer-macros [ js/document (.getElementById masto-embed) (.getAttribute "host_url"))) - (defn account-name-from-document [] + (-> js/document (.getElementById masto-embed) (.getAttribute "account_name"))) @@ -42,8 +44,40 @@ (.-innerHTML) (set! input))) +(defn debug [elem] + (print elem) + elem) + + +(defn find-account-id [host-url account-name] + (let [in (chan) + out (chan)] + (go + (->> + (! out)) + (do (close! in) + (close! out)) + ) + ;(api/get-directory host-url #(go (>! in %))) + out)) + (defn init [] - (api/get-account-statuses - (host-url-from-document) - (account-id-from-document) - render-to-document)) \ No newline at end of file + (go + (let [account-id (or + (account-id-from-document) + (