added suggestions

This commit is contained in:
2022-07-26 07:01:18 -07:00
parent 96c80853ef
commit 84f7e734f0
65 changed files with 130 additions and 1140 deletions

View File

@@ -39,15 +39,6 @@
[k v])))
(into {} )))))))
(re-frame/reg-fx
:new-window
(fn [url]
(.open js/window url)))
#_(re-frame/reg-fx
:dispatch-sync
(fn [event]
(re-frame/dispatch-sync event)))
(re-frame/reg-fx
:set-local-storage
@@ -121,47 +112,6 @@
(conj on-success)
(re-frame/dispatch))))))))
(re-frame/reg-fx
:https
(fn [{:keys [requests on-success on-failure owns-state]}]
(go
(when (:multi owns-state)
(re-frame/dispatch-sync [::status/loading-multi (:multi owns-state) (:which owns-state)]))
(when (:single owns-state)
(re-frame/dispatch-sync [::status/loading (:single owns-state)]))
(let [results (->>
(for [{:keys [method body headers uri token]} requests]
(go
(let [headers (if token
(assoc headers "Authorization" (str "Token " token))
headers)
response (<! (http/request {:method method
:body body
:headers headers
:url uri}))]
(if (>= (:status response) 400)
:error
:success))))
(async/merge)
(async/reduce conj [])
(async/<!))]
(println "DONE")
(if (some #{:error} results)
(do
(when (:multi owns-state)
(re-frame/dispatch [::status/error-multi (:multi owns-state) (:which owns-state) results]))
(when (:single owns-state)
(re-frame/dispatch [::status/error (:single owns-state) results]))
(re-frame/dispatch on-failure))
(do
(when (:multi owns-state)
(re-frame/dispatch [::status/completed-multi (:multi owns-state) (:which owns-state)]))
(when (:single owns-state)
(re-frame/dispatch [::status/completed (:single owns-state)]))
(re-frame/dispatch on-success)))))))
(defn kebab->snake [s]
(str/replace s #"-" "_"))