 (ns pc.replay
   (:require [datomic.api :as d]
             [pc.datomic :as pcd]
-            [pc.datomic.schema :as schema]))
+            [pc.datomic.schema :as schema]
+            [pc.datomic.web-peer :as web-peer])
+  (:import java.util.UUID))
 
 (defn get-document-transactions
   "Gets the broadcasted transactions for a document"

                            (remove #(= (:e %) (:db/id t)))
                            (map #(if (= (:v %) (:db/id doc))
                                    (assoc % :v (:db/id new-doc))
                                    %))))))
        eid-translations (-> (apply concat (map #(map :e %) tx-datas))
                           set
                           (disj (:db/id doc))

    (map ->datom)
    set))

(defn replace-frontend-ids [db doc-id txes]
  (let [a (d/entid db :frontend/id)]
    (map (fn [tx]
           (if (= (:a tx) a)
             (assoc tx
                    :v (UUID. doc-id (web-peer/client-part (:v tx)))
                    :a (d/entid (pcd/default-db) :frontend/id))
             tx))
         txes)))

(defn copy-transactions [db doc new-doc & {:keys [sleep-ms]
                                           :or {sleep-ms 1000}}]
  (let [conn (pcd/conn)
