            :duration (reduce #(+ %1 (first %2)) 0 asciicast)
            :frames (build-v0-frames asciicast))))
 
-(defmethod initialize-asciicast 1 [dispatch state asciicast]
+(defmethod initialize-asciicast 1 [state asciicast]
   (assoc state
          :loading false
          :width (or (:width state) (:width asciicast))


(defn handle-toggle-play
  "Toggles the playback. Fetches frames if they were not loaded yet."
  [state dispatch]
  (if (contains? state :frames)
    (if (contains? state :stop)
      (stop-playback state)
      (start-playback state dispatch))
    (fetch-asciicast state dispatch)))

(defn handle-seek
  "Jumps to a given position (in seconds)."
  [state dispatch [position]]
  (let [new-time (* position (:duration state))
        screen-state (screen-state-at (:frames state) new-time)
        playing? (contains? state :stop)]

  {:lines (vt/compact-lines lines)
   :cursor cursor})

(defmulti initialize-asciicast (fn [state asciicast]
                                 (if (vector? asciicast)
                                   0
                                   (:version asciicast))))

(defmethod initialize-asciicast 0 [state asciicast]
  (let [frame-0-lines (-> asciicast first last :lines)
        width (->> frame-0-lines vals first (map #(count (first %))) (reduce +))
        height (count frame-0-lines)]
