mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: no unlinked references
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
[logseq.shui.hooks :as hooks]
|
||||
[logseq.shui.ui :as shui]
|
||||
[missionary.core :as m]
|
||||
[rum.core :as rum]))
|
||||
[rum.core :as rum]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(rum/defc references-aux
|
||||
[page-entity config]
|
||||
@@ -77,11 +78,10 @@
|
||||
(when-let [id (:db/id entity)]
|
||||
(let [[has-references? set-has-references!] (hooks/use-state nil)]
|
||||
(hooks/use-effect!
|
||||
#(c.m/run-task*
|
||||
(m/sp
|
||||
(let [result (c.m/<? (state/<invoke-db-worker :thread-api/block-refs-check
|
||||
(state/get-current-repo) id {:unlinked? true}))]
|
||||
(set-has-references! result))))
|
||||
(fn []
|
||||
(p/let [result (state/<invoke-db-worker :thread-api/block-refs-check
|
||||
(state/get-current-repo) id {:unlinked? true})]
|
||||
(set-has-references! result)))
|
||||
[])
|
||||
(when has-references?
|
||||
(let [config (assoc config :highlight-query (:block/title entity))]
|
||||
|
||||
@@ -707,19 +707,18 @@
|
||||
|
||||
(def-thread-api :thread-api/block-refs-check
|
||||
[repo id {:keys [unlinked?]}]
|
||||
(m/sp
|
||||
(when-let [conn (worker-state/get-datascript-conn repo)]
|
||||
(let [db @conn
|
||||
block (d/entity db id)]
|
||||
(if unlinked?
|
||||
(let [title (string/lower-case (:block/title block))
|
||||
result (m/? (search-blocks repo title {:limit 100}))]
|
||||
(boolean (some (fn [b]
|
||||
(let [block (d/entity db (:db/id b))]
|
||||
(and (not= id (:db/id block))
|
||||
(not ((set (map :db/id (:block/refs block))) id))
|
||||
(string/includes? (string/lower-case (:block/title block)) title)))) result)))
|
||||
(some? (first (common-initial-data/get-block-refs db (:db/id block)))))))))
|
||||
(when-let [conn (worker-state/get-datascript-conn repo)]
|
||||
(let [db @conn
|
||||
block (d/entity db id)]
|
||||
(if unlinked?
|
||||
(let [title (string/lower-case (:block/title block))
|
||||
result (search-blocks repo title {:limit 100})]
|
||||
(boolean (some (fn [b]
|
||||
(let [block (d/entity db (:db/id b))]
|
||||
(and (not= id (:db/id block))
|
||||
(not ((set (map :db/id (:block/refs block))) id))
|
||||
(string/includes? (string/lower-case (:block/title block)) title)))) result)))
|
||||
(some? (first (common-initial-data/get-block-refs db (:db/id block))))))))
|
||||
|
||||
(def-thread-api :thread-api/get-block-parents
|
||||
[repo id depth]
|
||||
|
||||
Reference in New Issue
Block a user