Sfoglia il codice sorgente

fix: can't delete annotated pdf

related to https://github.com/logseq/db-test/issues/564
Tienson Qin 2 mesi fa
parent
commit
76d8546604
1 ha cambiato i file con 9 aggiunte e 7 eliminazioni
  1. 9 7
      deps/db/src/logseq/db/common/delete_blocks.cljs

+ 9 - 7
deps/db/src/logseq/db/common/delete_blocks.cljs

@@ -26,16 +26,18 @@
 (defn- build-retracted-tx
   [retracted-blocks]
   (let [refs (->> (mapcat (fn [block] (:block/_refs block)) retracted-blocks)
-                  (common-util/distinct-by :db/id))]
+                  (common-util/distinct-by :db/id))
+        retract-ids (set (map :db/id retracted-blocks))]
     (mapcat
      (fn [ref]
        (let [id (:db/id ref)
-             replaced-title (when-let [raw-title (:block/raw-title ref)]
-                              (reduce
-                               (fn [raw-title block]
-                                 (replace-ref-with-deleted-block-title block raw-title))
-                               raw-title
-                               retracted-blocks))
+             replaced-title (when-not (contains? retract-ids id)
+                              (when-let [raw-title (:block/raw-title ref)]
+                                (reduce
+                                 (fn [raw-title block]
+                                   (replace-ref-with-deleted-block-title block raw-title))
+                                 raw-title
+                                 retracted-blocks)))
              tx (cond->
                  (mapcat
                   (fn [block]