Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Jun 6, 2020
1 parent 7da7c7d commit dad3de9
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/conduit/ui/edit/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
(doseq [ref @refs]
(.clear ^js ref))))

(defn upsert-article [content refs slug]
(re-frame/dispatch
[:upsert-article
{:slug slug
:article {:title (string/trim (or (:title content) ""))
:description (string/trim (or (:description content) ""))
:body (string/trim (or (:body content) ""))
:tagList (string/split (:tagList content) #" ")}}
(reset-fields content refs)]))
(defn upsert-article [default content-atom refs slug]
(let [content (merge default @content-atom)]
(re-frame/dispatch
[:upsert-article
{:slug slug
:article {:title (string/trim (or (:title content) ""))
:description (string/trim (or (:description content) ""))
:body (string/trim (or (:body content) ""))
:tagList (string/split (:tagList content) #" ")}}
(reset-fields content-atom refs)])))

(defn editor []
(let [content (atom {})
Expand Down Expand Up @@ -54,8 +55,9 @@
:on-change-text #(swap! content assoc :tagList %)
:placeholder "Enter tags"
:default-value (str tagList)}]
[ui/button {:on-press #(upsert-article (merge {:title title :description description
:body body :tagList tagList :slug slug} @content)
[ui/button {:on-press #(upsert-article {:title title :description description
:body body :tagList tagList :slug slug}
content
refs
slug)
:title (if active-article
Expand Down

0 comments on commit dad3de9

Please sign in to comment.