 
 (go (let [cards (<! cards-channel)
           decks (process-decks (:json (<! (GET (str "/data/decks")))))]
-      (swap! app-state assoc :decks decks)
+      (load-decks decks)
       (go (let [data (<! auth-channel)]
-            (swap! app-state assoc :decks (process-decks (:decks data)))))
+            (load-decks (process-decks (:decks data)))))
       (>! cards-channel cards)))
 
 (defn side-identities [side]

                                      (<= new-qty 0) rest
                                      :else (conj rest {:qty new-qty :card card}))]
                  (om/set-state! owner [:deck :cards] new-cards))
                (deck->str owner))))))

    om/IDidUpdate
    (did-update [this prev-props prev-state]
      (let [deck (:deck prev-state)]
        (when-not (some #{deck} decks)
          (om/set-state! owner :deck (first (sort-by :date > decks))))))

    om/IRenderState
    (render-state [this state]


(def app-state (atom {:decks []}))

(def select-channel (chan))

(defn load-decks [decks]
  (swap! app-state assoc :decks decks)
  (put! select-channel (first (sort-by :date > decks))))

(defn process-decks [decks]
  (for [deck decks]
    (let [cards (map #(str (:qty %) " " (:card %)) (:cards deck))]
