 
 (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"))
+  (put! (om/get-state owner :edit-channel)
+        {:qty (js/parseInt (om/get-state owner :quantity))
+         :card (first (om/get-state owner :matches))})
   (om/set-state! owner :quantity 3)
   (om/set-state! owner :query "")
   (-> ".deckedit .lookup" js/$ .focus))

        [:form.card-search {:on-submit #(handle-add owner %)}
         [:input.lookup {:type "text" :placeholder "Card" :value (:query state)
                         :on-change #(om/set-state! owner :query (.. % -target -value))
                         :on-key-down #(handle-keydown owner %)
                         :on-blur #(om/set-state! owner :matches [])}] " x "
         [:input.qty {:type "text" :value (:quantity state)
                      :on-change #(om/set-state! owner :quantity (.. % -target -value))}]
         [:button "Add to deck"]


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