|
|
@@ -970,17 +970,14 @@
|
|
|
(when-let [conn (conn/get-conn repo)]
|
|
|
(let [page-id (:db/id (db-utils/entity [:block/name page]))
|
|
|
pattern (re-pattern (str "(?i)(?<!#)(?<!\\[\\[)" page "(?!\\]\\])"))]
|
|
|
- (->> (react/q repo [:block/unlinked-refs page-id] {}
|
|
|
- '[:find [(pull ?block ?block-attrs) ...]
|
|
|
- :in $ ?pattern ?block-attrs ?page-id
|
|
|
- :where
|
|
|
- [?block :block/content ?content]
|
|
|
- [?block :block/page ?page]
|
|
|
- [(not= ?page ?page-id)]
|
|
|
- [(re-find ?pattern ?content)]]
|
|
|
- pattern
|
|
|
- block-attrs
|
|
|
- page-id)
|
|
|
+ (->> (react/q repo [:block/unlinked-refs page-id]
|
|
|
+ {:query-fn (fn [db]
|
|
|
+ (let [ids (->> (d/datoms db :aevt :block/content)
|
|
|
+ (filter #(re-find pattern (:v %)))
|
|
|
+ (map :e))
|
|
|
+ result (d/pull-many db block-attrs ids)]
|
|
|
+ (remove (fn [block] (= page-id (:db/id (:block/page block)))) result)))}
|
|
|
+ nil)
|
|
|
react
|
|
|
(sort-by-left-recursive)
|
|
|
db-utils/group-by-page)))))
|