File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed
outliner/src/logseq/outliner Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 158158 (remove empty?))
159159 delete-blocks-tx (when-not (string? repo-or-conn)
160160 (delete-blocks/update-refs-history-and-macros @repo-or-conn tx-data tx-meta))
161- tx-data (concat tx-data delete-blocks-tx)]
161+ tx-data (distinct ( concat tx-data delete-blocks-tx) )]
162162
163163 ; ; Ensure worker can handle the request sequentially (one by one)
164164 ; ; Because UI assumes that the in-memory db has all the data except the last one transaction
Original file line number Diff line number Diff line change 431431 (assoc-level-aux tree-vec children-key 1 ))
432432
433433(defn- assign-temp-id
434- [blocks replace-empty-target? target-block]
434+ [db blocks replace-empty-target? target-block]
435435 (->> blocks
436436 (map-indexed
437437 (fn [idx block]
445445 [(assoc block
446446 :db/id (:db/id target-block)
447447 :block/uuid (:block/uuid target-block))]
448- [[:db/retractEntity (:db/id target-block)] ; retract target-block first
449- (assoc block :db/id db-id)])
448+ (let [old-property-values (d/q
449+ '[:find ?b ?a
450+ :in $ ?v
451+ :where
452+ [?b ?a ?v]
453+ [?v :block/uuid ]]
454+ db
455+ (:db/id target-block))
456+ from-property (:logseq.property/created-from-property target-block)]
457+ (concat
458+ [[:db/retractEntity (:db/id target-block)] ; retract target-block first
459+ (cond-> (assoc block :db/id db-id)
460+ from-property
461+ (assoc :logseq.property/created-from-property (:db/id from-property)))]
462+ (map (fn [[b a]]
463+ [:db/add b a db-id])
464+ old-property-values))))
450465 [(assoc block :db/id db-id)]))))
451466 (apply concat)))
452467
827842 :tx (vec blocks-tx)
828843 :blocks (vec blocks)
829844 :target-block target-block}))
830- (let [tx (assign-temp-id blocks-tx replace-empty-target? target-block)
845+ (let [tx (assign-temp-id db blocks-tx replace-empty-target? target-block)
831846 old-db-id-blocks (->> (filter :block.temp/use-old-db-id? tx)
832847 (map :block/uuid )
833848 (set ))
You can’t perform that action at this time.
0 commit comments