 (defn clear-subscriber [tick-state tick]
   (add-tick tick-state tick (fn [owner]
                               ((om/get-shared owner :cast!)
-                               :subscriber-updated {:client-id (ffirst state/subscriber-bot)
-                                                    :fields {:mouse-position nil
-                                                             :tool nil
-                                                             :show-mouse? false}}))))
+                               :subscriber-updated {:client-id (:client-id state/subscriber-bot)
+                                                    :fields (merge state/subscriber-bot {:mouse-position nil
+                                                                                         :tool nil
+                                                                                         :show-mouse? false})}))))
 
 (defn move-mouse [tick-state {:keys [start-tick end-tick start-x end-x start-y end-y tool]
                               :or {tool :rect}}]

                                                   (/ (- end-y start-y)
                                                      (- end-tick start-tick))))]
                              ((om/get-shared owner :cast!)
                               :subscriber-updated {:client-id (ffirst state/subscriber-bot)
                                                    :fields {:mouse-position [ex ey]
                                                             :show-mouse? true
                                                             :tool tool}})))))
              tick-state
              (range 0 (inc (- end-tick start-tick))))
    (annotate-keyframes end-tick)))

(defn draw-shape [tick-state {:keys [start-tick end-tick start-x end-x
                                     start-y end-y type tool doc-id props]
                              :or {type :rect
                                   tool :rect}}]
  (let [base-layer (merge {:layer/start-x start-x
                           :layer/start-y start-y
                           :layer/end-x end-x
                           :layer/end-y end-y
                           :layer/type (keyword "layer.type" (name type))
                           :layer/name "placeholder"
                           :layer/stroke-width 1
                           :document/id doc-id
                           :db/id (inc (rand-int 1000))}
                          props)
        ;; number of ticks to pause before saving layer
        pause-ticks 2]

      (add-tick end-tick
                (fn [owner]
                  ((om/get-shared owner :cast!)
                   :subscriber-updated {:client-id (:client-id state/subscriber-bot)
                                        :fields (merge state/subscriber-bot {:mouse-position nil
                                                                             :layers nil
                                                                             :tool :text})})
                  (d/transact! (om/get-shared owner :db) [base-layer] {:bot-layer true})))
      (annotate-keyframes start-tick end-tick))))

(defn clear-ticks [tick-state ticks]
  (update-in tick-state [:ticks] #(apply dissoc % ticks)))
