mirror of https://github.com/logseq/logseq
Remove unused :block/block queries from cache
parent
ec4ab8c446
commit
be6a8c3762
|
@ -1182,9 +1182,32 @@
|
||||||
[(?pred $ ?meta)]])
|
[(?pred $ ?meta)]])
|
||||||
react))))
|
react))))
|
||||||
|
|
||||||
|
(defn get-block-and-children-no-cache
|
||||||
|
[repo block-uuid]
|
||||||
|
(let [block (entity repo [:block/uuid block-uuid])
|
||||||
|
page (:db/id (:block/page block))
|
||||||
|
pos (:start-pos (:block/meta block))
|
||||||
|
level (:block/level block)
|
||||||
|
pred (fn []
|
||||||
|
(let [block (entity repo [:block/uuid block-uuid])
|
||||||
|
pos (:start-pos (:block/meta block))]
|
||||||
|
(fn [data meta]
|
||||||
|
(>= (:start-pos meta) pos))))]
|
||||||
|
(-> (d/q
|
||||||
|
'[:find (pull ?block [*])
|
||||||
|
:in $ ?page ?pred
|
||||||
|
:where
|
||||||
|
[?block :block/page ?page]
|
||||||
|
[?block :block/meta ?meta]
|
||||||
|
[(?pred $ ?meta)]]
|
||||||
|
(get-conn repo)
|
||||||
|
page
|
||||||
|
pred)
|
||||||
|
(block-and-children-transform repo block-uuid level))))
|
||||||
|
|
||||||
(defn block-has-children?
|
(defn block-has-children?
|
||||||
[repo block]
|
[repo block]
|
||||||
(let [blocks (get-block-and-children repo (:block/uuid block))
|
(let [blocks (get-block-and-children-no-cache repo (:block/uuid block))
|
||||||
second-block (second blocks)]
|
second-block (second blocks)]
|
||||||
(and second-block
|
(and second-block
|
||||||
(> (:block/level second-block) (:block/level block)))))
|
(> (:block/level second-block) (:block/level block)))))
|
||||||
|
@ -2102,7 +2125,7 @@
|
||||||
([repo block-id]
|
([repo block-id]
|
||||||
(get-block-full-content repo block-id (fn [block] (:block/content block))))
|
(get-block-full-content repo block-id (fn [block] (:block/content block))))
|
||||||
([repo block-id transform-fn]
|
([repo block-id transform-fn]
|
||||||
(let [blocks (get-block-and-children repo block-id false)]
|
(let [blocks (get-block-and-children-no-cache repo block-id)]
|
||||||
(->> blocks
|
(->> blocks
|
||||||
(map transform-fn)
|
(map transform-fn)
|
||||||
(apply util/join-newline)))))
|
(apply util/join-newline)))))
|
||||||
|
|
|
@ -709,7 +709,7 @@
|
||||||
collapsed? (:block/collapsed? block)
|
collapsed? (:block/collapsed? block)
|
||||||
repo (or (:block/repo block) (state/get-current-repo))
|
repo (or (:block/repo block) (state/get-current-repo))
|
||||||
last-child (and collapsed?
|
last-child (and collapsed?
|
||||||
(last (db/get-block-and-children repo (:block/uuid block))))
|
(last (db/get-block-and-children-no-cache repo (:block/uuid block))))
|
||||||
last-child (when (not= (:block/uuid last-child)
|
last-child (when (not= (:block/uuid last-child)
|
||||||
(:block/uuid block))
|
(:block/uuid block))
|
||||||
last-child)]
|
last-child)]
|
||||||
|
@ -1508,10 +1508,10 @@
|
||||||
(when-let [sibling-block-id (d/attr sibling-block "blockid")]
|
(when-let [sibling-block-id (d/attr sibling-block "blockid")]
|
||||||
(when-let [sibling-block (db/pull-block (medley/uuid sibling-block-id))]
|
(when-let [sibling-block (db/pull-block (medley/uuid sibling-block-id))]
|
||||||
(let [sibling-meta (:block/meta sibling-block)
|
(let [sibling-meta (:block/meta sibling-block)
|
||||||
hc1 (db/get-block-and-children repo (:block/uuid block) false)
|
hc1 (db/get-block-and-children-no-cache repo (:block/uuid block))
|
||||||
hc2 (if (or move-upwards-to-parent? move-down-to-higher-level?)
|
hc2 (if (or move-upwards-to-parent? move-down-to-higher-level?)
|
||||||
[sibling-block]
|
[sibling-block]
|
||||||
(db/get-block-and-children repo (:block/uuid sibling-block) false))]
|
(db/get-block-and-children-no-cache repo (:block/uuid sibling-block)))]
|
||||||
;; Same page and next to the other
|
;; Same page and next to the other
|
||||||
(when (and
|
(when (and
|
||||||
(= (:db/id (:block/page block))
|
(= (:db/id (:block/page block))
|
||||||
|
|
Loading…
Reference in New Issue