From 4dfadfaaf91cf5c3575113987f8fbbf4436c0fd2 Mon Sep 17 00:00:00 2001 From: rcmerci Date: Thu, 25 Nov 2021 12:14:21 +0800 Subject: [PATCH] add left+parent check after transact --- .../frontend/modules/outliner/datascript.cljc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/frontend/modules/outliner/datascript.cljc b/src/main/frontend/modules/outliner/datascript.cljc index 7965a3c15..bbaded6f8 100644 --- a/src/main/frontend/modules/outliner/datascript.cljc +++ b/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))))))