Browse Source

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

or extracted blocks from the current file.
Tienson Qin 5 months ago
parent
commit
4ed15c7dac

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

@@ -70,7 +70,7 @@ Options available:
                             :as options}]
    (let [format (common-util/get-format 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)
                                         :date-formatter "MMM do, yyyy"
                                         :uri-encoded? false
@@ -109,7 +109,9 @@ Options available:
                           (assoc :file/created-at (or ctime (js/Date.)))
                           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
   "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"
   [db page-name *extracted-block-ids 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)
                 block)]
     (swap! *extracted-block-ids conj (:block/uuid block))