finished POC for filtering by favorited replies

master
bom 2 years ago
parent ec73ff83e3
commit 44177d5c0b

@ -59,13 +59,30 @@
first)))
out))
(defn favorited-replies? [host-url reply-id account-name]
(go
(infra/debug (->>
(<p! (api/get-favorited-by host-url reply-id))
api/mastojs->edn
(filter #(= account-name (:acct %)))
(infra/debug)))))
(defn favorited-replies? [host-url account-name reply-id]
(let [out (chan)]
(go
(>! out
(->>
(<p! (api/get-favorited-by host-url reply-id))
api/mastojs->edn
(filter #(= account-name (:acct %)))
(empty?)
(not))))
out))
(defn favorited? [host-url account-name replies]
(let [out (chan)]
(go
(>! out
(loop [loc-replies replies
result []]
(if (empty? loc-replies)
result
(recur (rest loc-replies)
(conj result (<! (favorited-replies? host-url account-name (first loc-replies)))))))))
out))
(defn init []
(go
@ -78,26 +95,20 @@
(<p! (api/get-account-statuses host-url account-id))
api/mastojs->edn)
test-status (->
(<p! (api/get-favorited-by host-url "107779739758156958"))
(<p! (api/get-replies host-url "107779492679907372"))
api/mastojs->edn)
filtered (filter (favorited-replies? host-url "107779739758156958" "bastian@digitalcourage.social") (:descendants test-status))
favorited (<! (favorited? host-url "bastian@digitalcourage.social" (map :id (:descendants test-status))))
combined (map (fn [s f] {:status s :favorited f}) (:descendants test-status) favorited)
filtered (map :status (filter :favorited combined))
]
;"107779739758156958"
;(->> statuus
; (take 4)
; (rb/masto->html)
; (render-html)
; (render-to-document))
;(go (infra/debug (<! (favorited-replies? host-url "107779739758156958" "team@meissa.social"))))
;(go (let [test (api/mastojs->edn (<p! (api/get-favorited-by host-url "107779739758156958")))]
; (infra/debug (filter #(= "team@meissa.social" (:acct %)) test))))
(infra/debug test-status)
(infra/debug filtered)
;(->> filtered
; (infra/debug)
; (rb/masto->html)
; (render-html)
; (render-to-document))
)))
(->> filtered
(infra/debug)
(rb/masto->html)
(render-html)
(render-to-document))
)))
Loading…
Cancel
Save