 
 (defn revert-to [i]
   (prn "request revert: " i)
-  (let [index (* (dec (count @(@current-branch :coll))) (/ i 100))]
+  (let [index (* (dec (len @(@current-branch :data))) (/ i 100))]
     (when-let [state (when (>= index 1) (nth-history index))]
       (prn "revert to: " index)
       (reset! app-state state)

      (branch-at @reverted-to n)
      ; else just append to history
      :else
      (let [b @(@current-branch :coll)]
        (when-not (= (last b) n)
          (swap! (@current-branch :coll) conj n))
        (let [c (+ (@current-branch :offset-index) (count b))]
            (prn (str c " Saved " (pluralize c "State")))))))



; (om/root
;   (fn [app owner]

      (move-indicator-to i))))

(defn add-new-branch [branch]
    (let [new-branch-morph (branch-morph 
                          5 (+ 5 (* branch-height (dec @branch-count))) 
                         (- diagram-width 0) branch-height branch)]
      (add-morph history-view "wrapper" new-branch-morph)
      (set-extent history-view "wrapper" {:x (+ diagram-width 10) :y (+ 10 (* branch-height @branch-count))})
      (switch-to-branch branch))
    (.log js/console (morphic/dict->js @history-view)))

;; snapshot the state when it is changed:

