fix: block ref numbers not updated unless re-indexed

Close #1673

Also, fixed an issue that update the block in references doesn't work
This commit is contained in:
Tienson Qin
2021-05-14 17:58:36 +08:00
parent 50f34b7859
commit e94a09beff
3 changed files with 18 additions and 15 deletions

View File

@@ -235,9 +235,10 @@
(apply concat
(for [{:block/keys [refs]} blocks]
(map (fn [page]
(when-let [page (db-utils/entity [:block/name (:block/name page)])]
[:block/refed-blocks (:db/id page)]))
(mapcat (fn [ref]
(when-let [block (db-utils/entity ref)]
[[:page/blocks (:db/id (:block/page block))]
[:block/refed-blocks (:db/id block)]]))
refs))))
(distinct))
refed-pages (map