Просмотр исходного кода

fix: recalculate whiteboard references on change

Peng Xiao 3 лет назад
Родитель
Сommit
def081679f

+ 5 - 1
src/main/frontend/handler/whiteboard.cljs

@@ -66,10 +66,14 @@
                                       (block-ids (:block/uuid (:block/parent block)))
                                       (not (gp-whiteboard/shape-block? block)))))
                                existing-blocks)
+        ;; always recalcuate refs for now. 
+        ;; todo: optimize in frontend.modules.outliner.pipeline/compute-block-path-refs?
+        refs-tx (mapcat (fn [m] [[:db/retract (:db/id m) :block/path-refs]
+                                 [:db/retract (:db/id m) :block/refs]]) existing-blocks)
         delete-blocks-tx (mapv (fn [s] [:db/retractEntity (:db/id s)]) delete-blocks)
         page-and-blocks (->> (cons page-block blocks)
                              (map outliner/block-with-timestamps))]
-    (concat page-and-blocks delete-blocks-tx)))
+    (concat refs-tx page-and-blocks delete-blocks-tx)))
 
 (defn- get-whiteboard-clj [page-name]
   (when (model/page-exists? page-name)

+ 2 - 0
src/main/frontend/modules/outliner/pipeline.cljs

@@ -18,6 +18,8 @@
 ;; and the new path-refs changes, which makes both undo/redo and
 ;; react-query/refresh! easier.
 
+;; TODO: also need to consider whiteboard transactions
+
 ;; Steps:
 ;; 1. For each changed block, new-refs = its page + :block/refs + parents :block/refs
 ;; 2. Its children' block/path-refs might need to be updated too.