浏览代码

fix: extracted-block-ids should be existing block from another page

or extracted blocks from the current file.
Tienson Qin 5 月之前
父节点
当前提交
4ed15c7dac

+ 4 - 2
deps/graph-parser/src/logseq/graph_parser.cljs

@@ -70,7 +70,7 @@ Options available:
                             :as options}]
                             :as options}]
    (let [format (common-util/get-format file-path)
    (let [format (common-util/get-format file-path)
          file-content [{:file/path file-path}]
          file-content [{:file/path file-path}]
-         {:keys [tx]}
+         {:keys [tx ast]}
          (let [extract-options' (merge {:block-pattern (common-config/get-block-pattern format)
          (let [extract-options' (merge {:block-pattern (common-config/get-block-pattern format)
                                         :date-formatter "MMM do, yyyy"
                                         :date-formatter "MMM do, yyyy"
                                         :uri-encoded? false
                                         :uri-encoded? false
@@ -109,7 +109,9 @@ Options available:
                           (assoc :file/created-at (or ctime (js/Date.)))
                           (assoc :file/created-at (or ctime (js/Date.)))
                           mtime
                           mtime
                           (assoc :file/last-modified-at mtime))])]
                           (assoc :file/last-modified-at mtime))])]
-     (ldb/transact! conn tx (select-keys options [:new-graph? :from-disk?])))))
+     (ldb/transact! conn tx (select-keys options [:new-graph? :from-disk?]))
+     {:tx tx
+      :ast ast})))
 
 
 (defn filter-files
 (defn filter-files
   "Filters files in preparation for parsing. Only includes files that are
   "Filters files in preparation for parsing. Only includes files that are

+ 2 - 3
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -702,9 +702,8 @@
   "If the block exists in another page or the current page, we need to fix it"
   "If the block exists in another page or the current page, we need to fix it"
   [db page-name *extracted-block-ids block]
   [db page-name *extracted-block-ids block]
   (let [existing-block (d/entity db [:block/uuid (:block/uuid block)])
   (let [existing-block (d/entity db [:block/uuid (:block/uuid block)])
-        block (if (and existing-block
-                       (or (not= (:block/name (:block/page existing-block)) page-name)
-                           (contains? @*extracted-block-ids (:block/uuid block))))
+        block (if (or (and existing-block (not= (:block/name (:block/page existing-block)) page-name))
+                      (contains? @*extracted-block-ids (:block/uuid block)))
                 (fix-duplicate-id block)
                 (fix-duplicate-id block)
                 block)]
                 block)]
     (swap! *extracted-block-ids conj (:block/uuid block))
     (swap! *extracted-block-ids conj (:block/uuid block))