 ;; update the now timestamps every 0.25 second
 ;; (js/setInterval update-now! 250)
 
-(defn- clear-compiled-info! [prj-key bld-idx]
-  (swap! state update-in [:projects prj-key :builds bld-idx]
+(defn- clear-compiled-info! [prj-key bld-id]
+  (swap! state update-in [:projects prj-key :builds bld-id]
     assoc :last-compile-time nil
           :error nil
           :warnings []))

  (swap! state assoc-in [:projects prj-key :state] :once)

  ;; update the BuildRows state
  (doall (map #(show-lein-startup! prj-key %) bld-ids))

  (remove-compiled-info! prj-key)


;; NOTE: this function will not work if two builds have the same output-to target
;; should probably refactor with a filter?
(defn- output-to->bld-id [prj-key output-to]
  (let [blds (vals (get-in @state [:projects prj-key :builds]))
        outputs (map #(-> % :compiler :output-to) blds)
        ids (map :id blds)
        m (zipmap outputs ids)]
    (get m output-to)))

(defn- num-selected-builds [prj]
  (->> prj
    :builds
    vals
    (map :active?)
    (remove false?)
    count))
