Skip to content

Commit

Permalink
add can-edit to submit-comment mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
myguidingstar committed Jan 7, 2021
1 parent da11aeb commit b4da5f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/conduit/handler/mutations.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
(defmutation submit-comment [{:keys [article-id diff]}]
(action [{:keys [state]}]
(swap! state #(let [ident (util/get-ident diff)
id (second ident)]
id (second ident)
current-user (get-in % [:session/session :current-user])]
(-> %
(update-in ident merge
(if (number? id)
#:comment{:updated-at (js/Date.)}
#:comment{:id id
:author (:user/whoami %)
#:comment{:id id
:author current-user
:can-edit true
:created-at (js/Date.)})
(util/get-item diff))
(update-in [:article/id article-id :article/comments]
Expand Down

0 comments on commit b4da5f5

Please sign in to comment.