         on5 #(when-not (get-state :on?) (set-time! (presets :five)))
         on-toggle #(set-state! :on? (not (get-state :on?)))
         on-reset #(when-not (get-state :on?)
-                    (set-state! (default-state (get-state :stime))))]
+                    (set-state! (default-state (get-state :time))))]
 
    [:div {:class "col-md-2 buttons"}
     [btn-lg {:on-click on25} 25]

  (if (= (:twenty-five presets) time)
    (:five presets)
    (:twenty-five presets)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Timer logic
(def ^:constant time-speed 1e3)

(def timer-chan
  (let [c (chan)

      (when-not (apply expired? (get-state :stime :etime))
        (set-state! :etime (dec-time (get-state :etime))))))


(add-watch state :end
           (fn [k r os ns]
             (when (and (get-state :on?) (apply expired? (get-state :stime :etime)))
               (put! end-chan true))))

(go (while true
      (<! end-chan)
      (>! bg-chan true)
      (play-sound) ;; ding!
      (set-state! (default-state (next-time (get-state :time)))))) ;; set next pomodoro session

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Background logic
(defn set-bg! [bg]
  (let [img (nth images (rand-int 2))]
    (set-state! :bg img)))

(go (while true
      (<! bg-chan)
      (swap! history conj (get-state :time))
      (when (apply pomodoro? (take-last 2 @history))
        (set-bg! (get-state :bg)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Generic Views
