 
 (defn edit-deck [owner]
   (om/set-state! owner :edit true)
-  (om/set-state! owner :deck-edit (deck->str (om/get-state owner [:deck :cards])))
+  (deck->str owner)
   (-> owner (om/get-node "viewport") js/$ (.addClass "edit"))
   (go (<! (timeout 500))
       (-> owner (om/get-node "deckname") js/$ .focus)))


(defn handle-add [owner event]
  (.preventDefault event)
  (put! (om/get-state owner :add-channel)
        (str (om/get-state owner :quantity) " " (om/get-state owner :query) "\n"))
  (om/set-state! owner :quantity 3)
  (om/set-state! owner :query "")
  (-> ".deckedit .lookup" js/$ .focus))

    om/IInitState
    (init-state [this]
      {:edit false
       :edit-channel (chan)
       :deck nil})

    om/IWillMount
    (will-mount [this]
      (let [edit-channel (om/get-state owner :edit-channel)]
        (go (while true
              (let [edit (<! edit-channel)
                    card (:card edit)
                    cards (om/get-state owner [:deck :cards])
                    match? #(when (= (get-in % [:card :title]) (:title card)) %)
                    existing-line (some match? cards)]
                (if existing-line
                  (let [new-qty (+ (:qty existing-line) (:qty edit))
                        other-cards (remove match? cards)
                        new-cards (cond (> new-qty 3) (conj other-cards {:qty 3 :card card})
                                        (<= new-qty 0) other-cards
                                        :else (conj other-cards {:qty new-qty :card card}))]
                    (om/set-state! owner [:deck :cards] new-cards))
                  (om/set-state! owner [:deck :cards] (conj cards edit)))
                (deck->str owner))))))

    om/IDidUpdate
    (did-update [this prev-props prev-state]
