mirror of
https://github.com/logseq/logseq.git
synced 2026-05-01 09:26:28 +00:00
fix: performance degrading for nested linked references
Fix #6316. This commit also fixed the issue that toggle block children doesn't work sometimes.
This commit is contained in:
@@ -3188,14 +3188,12 @@
|
||||
:or {semantic? false}}]
|
||||
(when block-id
|
||||
(if-let [block (db-model/query-block-by-uuid block-id)]
|
||||
(and
|
||||
(not (util/collapsed? block))
|
||||
(or (db-model/has-children? block-id)
|
||||
(and
|
||||
(:outliner/block-title-collapse-enabled? (state/get-config))
|
||||
(block-with-title? (:block/format block)
|
||||
(:block/content block)
|
||||
semantic?))))
|
||||
(or (db-model/has-children? block-id)
|
||||
(and
|
||||
(:outliner/block-title-collapse-enabled? (state/get-config))
|
||||
(block-with-title? (:block/format block)
|
||||
(:block/content block)
|
||||
semantic?)))
|
||||
false))))
|
||||
|
||||
(defn all-blocks-with-level
|
||||
@@ -3282,6 +3280,8 @@
|
||||
(let [block {:block/uuid block-id
|
||||
:block/collapsed? value}]
|
||||
(outliner-core/save-block! block)))))))
|
||||
(doseq [block-id block-ids]
|
||||
(state/set-collapsed-block! block-id value))
|
||||
(let [block-id (first block-ids)
|
||||
input-pos (or (state/get-edit-pos) :max)]
|
||||
;; update editing input content
|
||||
@@ -3294,13 +3294,11 @@
|
||||
(defn collapse-block! [block-id]
|
||||
(when (collapsable? block-id)
|
||||
(when-not (skip-collapsing-in-db?)
|
||||
(set-blocks-collapsed! [block-id] true)))
|
||||
(state/set-collapsed-block! block-id true))
|
||||
(set-blocks-collapsed! [block-id] true))))
|
||||
|
||||
(defn expand-block! [block-id]
|
||||
(when-not (skip-collapsing-in-db?)
|
||||
(set-blocks-collapsed! [block-id] false)
|
||||
(state/set-collapsed-block! block-id false)))
|
||||
(set-blocks-collapsed! [block-id] false)))
|
||||
|
||||
(defn expand!
|
||||
([e] (expand! e false))
|
||||
@@ -3373,12 +3371,15 @@
|
||||
|
||||
(defn collapse-all!
|
||||
([]
|
||||
(collapse-all! nil))
|
||||
([block-id]
|
||||
(collapse-all! nil {}))
|
||||
([block-id {:keys [collapse-self?]
|
||||
:or {collapse-self? true}}]
|
||||
(let [blocks (all-blocks-with-level {:incremental? false
|
||||
:expanded? true
|
||||
:root-block block-id})
|
||||
block-ids (map :block/uuid blocks)]
|
||||
block-ids (cond->> (mapv :block/uuid blocks)
|
||||
(not collapse-self?)
|
||||
(remove #{block-id}))]
|
||||
(set-blocks-collapsed! block-ids true))))
|
||||
|
||||
(defn expand-all!
|
||||
@@ -3398,6 +3399,14 @@
|
||||
(collapse-all!)
|
||||
(expand-all!))))
|
||||
|
||||
(defn toggle-open-block-children! [block-id]
|
||||
(let [all-expanded? (empty? (all-blocks-with-level {:incremental? false
|
||||
:collapse? true
|
||||
:root-block block-id}))]
|
||||
(if all-expanded?
|
||||
(collapse-all! block-id {:collapse-self? false})
|
||||
(expand-all! block-id))))
|
||||
|
||||
(defn select-all-blocks!
|
||||
[]
|
||||
(if-let [current-input-id (state/get-edit-input-id)]
|
||||
@@ -3484,8 +3493,7 @@
|
||||
(or
|
||||
(and
|
||||
(or (:ref? config) (:custom-query? config))
|
||||
(>= (inc (:block/level block))
|
||||
(state/get-ref-open-blocks-level))
|
||||
(>= (:block/level block) (state/get-ref-open-blocks-level))
|
||||
;; has children
|
||||
(first (:block/_parent (db/entity (:db/id block)))))
|
||||
(util/collapsed? block)))
|
||||
|
||||
Reference in New Issue
Block a user