Only update edited recipes if the recipe changed

This commit is contained in:
Nicholas Kariniemi 2014-10-10 20:39:47 +03:00
parent 14427e89d9
commit 07e85a4d30

View file

@ -36,9 +36,13 @@
(condp = [current next]
[:editing :waiting] (let [recipe (om/get-props owner)
name (om/get-state owner :name)
grubs (om/get-state owner :grubs)]
(om/transact! recipe nil #(assoc % :name name :grubs grubs) :local))
(when-not (and (= name (:name @recipe))
(= grubs (:grubs @recipe)))
(om/transact! recipe
nil
#(assoc % :name name :grubs grubs)
:local)))
nil)
(when-not (= current next) (om/set-state! owner :edit-state next))))