Browse Source

add left+parent check after transact

rcmerci 4 years ago
parent
commit
4dfadfaaf9
1 changed files with 13 additions and 2 deletions
  1. 13 2
      src/main/frontend/modules/outliner/datascript.cljc

+ 13 - 2
src/main/frontend/modules/outliner/datascript.cljc

@@ -44,9 +44,20 @@
                editor-cursor (state/get-current-edit-block-and-position)
                meta (merge opts {:editor-cursor editor-cursor})
                rs (d/transact! conn txs meta)]
+           (when true                 ; TODO: add debug flag
+             (let [eids (distinct (mapv first (:tx-data rs)))
+                   left&parent-list (->>
+                                     (d/q '[:find ?e ?l ?p
+                                            :in $ [?e ...]
+                                            :where
+                                            [?e :block/left ?l]
+                                            [?e :block/parent ?p]] @conn eids)
+                                     (vec)
+                                     (map next))]
+               (assert (= (count left&parent-list) (count (distinct left&parent-list))) eids)))
            (when-not config/test?
-            (after-transact-pipelines rs))
-          rs)
+             (after-transact-pipelines rs))
+           rs)
          (catch js/Error e
            (log/error :exception e)
            (throw e))))))