Skip to content

Commit

Permalink
fix: compute old-refs using db-before
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed May 4, 2023
1 parent f70fbaf commit a3b60a3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/frontend/modules/outliner/pipeline.cljs
Expand Up @@ -6,7 +6,8 @@
[frontend.db.model :as db-model]
[frontend.db.react :as react]
[frontend.db :as db]
[clojure.set :as set]))
[clojure.set :as set]
[datascript.core :as d]))

(defn updated-page-hook
[tx-report page]
Expand All @@ -24,7 +25,7 @@
;; 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.
(defn compute-block-path-refs
[{:keys [tx-meta]} blocks]
[{:keys [tx-meta db-before]} blocks]
(let [repo (state/get-current-repo)
blocks (remove :block/name blocks)]
(when (:outliner-op tx-meta)
Expand All @@ -36,7 +37,7 @@
(let [parents (db-model/get-block-parents repo (:block/uuid block))
parents-refs (->> (mapcat :block/path-refs parents)
(map :db/id))
old-refs (set (map :db/id (:block/path-refs block)))
old-refs (set (map :db/id (:block/path-refs (d/entity db-before (:db/id block)))))
new-refs (set (util/concat-without-nil
[(:db/id (:block/page block))]
(map :db/id (:block/refs block))
Expand Down

0 comments on commit a3b60a3

Please sign in to comment.