mirror of
https://github.com/logseq/logseq.git
synced 2026-05-01 01:16:27 +00:00
fix: wrong usage of :frontend.db.react/refs
Previously, `[:frontend.db.react/refs id]` is used for three places: 1. get-page-referenced-blocks 2. get-block-referenced-blocks 3. get-block-references-count The cached query atom will be shared between those three functions, the problem is that both queries in `get-page-referenced-blocks` and `get-block-referenced-blocks` return data of different formats, which can result in crashes in some situations (e.g. PR #8423). This commit removed `get-block-references-count` and use `model/pull-block` and `(count (:block/_refs block))` instead. We also need to make sure the `id` in `[:frontend.db.react/refs id]` will be different for `get-page-referenced-blocks` and `get-block-referenced-blocks`. We can probably get rid of `get-page-referenced-blocks` once we refactored both linked references and filters for pages.
This commit is contained in:
@@ -257,9 +257,11 @@
|
||||
(:db/id (:block/page block)))
|
||||
blocks [[::block (:db/id block)]]
|
||||
path-refs (:block/path-refs block)
|
||||
path-refs' (keep (fn [ref]
|
||||
(when-not (= (:db/id ref) page-id)
|
||||
[::refs (:db/id ref)])) path-refs)
|
||||
path-refs' (->> (keep (fn [ref]
|
||||
(when-not (= (:db/id ref) page-id)
|
||||
[[::refs (:db/id ref)]
|
||||
[::block (:db/id ref)]])) path-refs)
|
||||
(apply concat))
|
||||
page-blocks (when page-id
|
||||
[[::page-blocks page-id]])]
|
||||
(concat blocks page-blocks path-refs')))
|
||||
@@ -267,7 +269,8 @@
|
||||
|
||||
(mapcat
|
||||
(fn [ref]
|
||||
[[::refs ref]])
|
||||
[[::refs ref]
|
||||
[::block ref]])
|
||||
refs)
|
||||
|
||||
(when-let [current-page-id (:db/id (get-current-page))]
|
||||
|
||||
Reference in New Issue
Block a user