mirror of https://github.com/logseq/logseq
fix: slow performance for block delete
parent
a3d5fc699d
commit
77bcd70a2a
|
@ -733,21 +733,16 @@
|
||||||
0)
|
0)
|
||||||
edit-target (if edit-block-has-refs?
|
edit-target (if edit-block-has-refs?
|
||||||
(db/pull (:db/id edit-block))
|
(db/pull (:db/id edit-block))
|
||||||
(db/pull (:db/id block)))
|
(db/pull (:db/id block)))]
|
||||||
input (state/get-input)
|
(edit-block! edit-target
|
||||||
edit-block-fn #(edit-block! (assoc edit-target :block/content new-value)
|
pos
|
||||||
pos
|
(state/get-edit-block-node)
|
||||||
(state/get-edit-block-node)
|
{:custom-content new-value
|
||||||
{:custom-content new-value
|
:tail-len tail-len})
|
||||||
:tail-len tail-len})]
|
|
||||||
(when (and edit-block-has-refs? input)
|
|
||||||
(state/set-edit-content! (state/get-edit-input-id) new-value)
|
|
||||||
(cursor/move-cursor-to input pos))
|
|
||||||
|
|
||||||
{:prev-block block
|
{:prev-block block
|
||||||
:new-content new-value
|
:new-content new-value
|
||||||
:pos pos
|
:pos pos}))))))
|
||||||
:edit-block-fn edit-block-fn}))))))
|
|
||||||
|
|
||||||
(declare save-block!)
|
(declare save-block!)
|
||||||
|
|
||||||
|
@ -757,7 +752,7 @@
|
||||||
|
|
||||||
(declare expand-block!)
|
(declare expand-block!)
|
||||||
(defn delete-block!
|
(defn delete-block!
|
||||||
[repo delete-children? & {:keys [*edit-block-fn]}]
|
[repo delete-children?]
|
||||||
(let [{:keys [id block-id block-parent-id value format config]} (get-state)]
|
(let [{:keys [id block-id block-parent-id value format config]} (get-state)]
|
||||||
(when block-id
|
(when block-id
|
||||||
(when-let [block-e (db/entity [:block/uuid block-id])]
|
(when-let [block-e (db/entity [:block/uuid block-id])]
|
||||||
|
@ -784,8 +779,7 @@
|
||||||
block-parent
|
block-parent
|
||||||
{:container (util/rec-get-blocks-container block-parent)})
|
{:container (util/rec-get-blocks-container block-parent)})
|
||||||
(util/get-prev-block-non-collapsed-non-embed block-parent))
|
(util/get-prev-block-non-collapsed-non-embed block-parent))
|
||||||
{:keys [prev-block new-content edit-block-fn]} (move-to-prev-block repo sibling-block format id value)
|
{:keys [prev-block new-content]} (move-to-prev-block repo sibling-block format id value)
|
||||||
_ (when *edit-block-fn (reset! *edit-block-fn edit-block-fn))
|
|
||||||
concat-prev-block? (boolean (and prev-block new-content))
|
concat-prev-block? (boolean (and prev-block new-content))
|
||||||
transact-opts {:outliner-op :delete-blocks}
|
transact-opts {:outliner-op :delete-blocks}
|
||||||
db-based? (config/db-based-graph? repo)]
|
db-based? (config/db-based-graph? repo)]
|
||||||
|
@ -860,11 +854,10 @@
|
||||||
(state/get-date-formatter)
|
(state/get-date-formatter)
|
||||||
blocks' {}))
|
blocks' {}))
|
||||||
(when sibling-block
|
(when sibling-block
|
||||||
(let [{:keys [edit-block-fn]} (move-to-prev-block repo sibling-block
|
(move-to-prev-block repo sibling-block
|
||||||
(:block/format block)
|
(:block/format block)
|
||||||
(dom/attr sibling-block "id")
|
(dom/attr sibling-block "id")
|
||||||
"")]
|
""))))))
|
||||||
(when edit-block-fn (edit-block-fn))))))))
|
|
||||||
|
|
||||||
(defn set-block-query-properties!
|
(defn set-block-query-properties!
|
||||||
[block-id all-properties key add?]
|
[block-id all-properties key add?]
|
||||||
|
@ -2812,11 +2805,7 @@
|
||||||
(p/do!
|
(p/do!
|
||||||
(save-current-block!)
|
(save-current-block!)
|
||||||
(remove-block-own-order-list-type! block))
|
(remove-block-own-order-list-type! block))
|
||||||
(let [*edit-block-fn (atom nil)
|
(delete-block! repo false))))
|
||||||
result (delete-block! repo false :*edit-block-fn *edit-block-fn)]
|
|
||||||
(when-let [f @*edit-block-fn]
|
|
||||||
(state/set-state! :editor/cached-edit-block-fn f))
|
|
||||||
result))))
|
|
||||||
|
|
||||||
(and (> current-pos 1)
|
(and (> current-pos 1)
|
||||||
(= (util/nth-safe value (dec current-pos)) commands/command-trigger))
|
(= (util/nth-safe value (dec current-pos)) commands/command-trigger))
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
(defn- update-current-tx-editor-cursor!
|
(defn- update-current-tx-editor-cursor!
|
||||||
[tx-report]
|
[tx-report]
|
||||||
(let [tx-id (get-tx-id tx-report)
|
(let [tx-id (get-tx-id tx-report)
|
||||||
editor-cursor (:ui/before-editor-cursor @state/state)]
|
editor-cursor @(:history/tx-before-editor-cursor @state/state)]
|
||||||
(state/update-state! :history/tx->editor-cursor
|
(state/update-state! :history/tx->editor-cursor
|
||||||
(fn [m] (assoc-in m [tx-id :before] editor-cursor)))
|
(fn [m] (assoc-in m [tx-id :before] editor-cursor)))
|
||||||
(state/set-state! :ui/before-editor-cursor nil)))
|
(state/set-state! :history/tx-before-editor-cursor nil)))
|
||||||
|
|
||||||
(defn restore-cursor-and-app-state!
|
(defn restore-cursor-and-app-state!
|
||||||
[{:keys [editor-cursor app-state]} undo?]
|
[{:keys [editor-cursor app-state]} undo?]
|
||||||
|
@ -47,10 +47,6 @@
|
||||||
tx-report {:tx-meta tx-meta
|
tx-report {:tx-meta tx-meta
|
||||||
:tx-data tx-data}]
|
:tx-data tx-data}]
|
||||||
|
|
||||||
(when-let [edit-block-f (:editor/cached-edit-block-fn @state/state)]
|
|
||||||
(edit-block-f)
|
|
||||||
(state/set-state! :editor/cached-edit-block-fn nil))
|
|
||||||
|
|
||||||
(let [conn (db/get-db repo false)
|
(let [conn (db/get-db repo false)
|
||||||
tx-report (d/transact! conn tx-data tx-meta)]
|
tx-report (d/transact! conn tx-data tx-meta)]
|
||||||
(when local-tx?
|
(when local-tx?
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
:conn (db/get-db false)
|
:conn (db/get-db false)
|
||||||
:unlinked-graph? frontend.modules.outliner.ui/unlinked-graph?
|
:unlinked-graph? frontend.modules.outliner.ui/unlinked-graph?
|
||||||
:set-state-fn frontend.modules.outliner.ui/set-state-fn}]
|
:set-state-fn frontend.modules.outliner.ui/set-state-fn}]
|
||||||
(when-not (:ui/before-editor-cursor @state/state)
|
(when (nil? @(:history/tx-before-editor-cursor @state/state))
|
||||||
(state/set-state! :ui/before-editor-cursor (state/get-current-edit-block-and-position)))
|
(state/set-state! :history/tx-before-editor-cursor (state/get-current-edit-block-and-position)))
|
||||||
(logseq.outliner.transaction/transact! (assoc ~opts :transact-opts transact-opts#)
|
(logseq.outliner.transaction/transact! (assoc ~opts :transact-opts transact-opts#)
|
||||||
~@body))))
|
~@body))))
|
||||||
|
|
|
@ -300,6 +300,7 @@
|
||||||
:whiteboard/last-persisted-at {}
|
:whiteboard/last-persisted-at {}
|
||||||
:whiteboard/pending-tx-data {}
|
:whiteboard/pending-tx-data {}
|
||||||
:history/page-only-mode? false
|
:history/page-only-mode? false
|
||||||
|
:history/tx-before-editor-cursor (atom nil)
|
||||||
;; db tx-id -> editor cursor
|
;; db tx-id -> editor cursor
|
||||||
:history/tx->editor-cursor (atom {})
|
:history/tx->editor-cursor (atom {})
|
||||||
:system/info {}
|
:system/info {}
|
||||||
|
|
Loading…
Reference in New Issue