Browse Source

fix: references not calculated right

related to https://github.com/logseq/db-test/issues/436#issuecomment-3217902953
Tienson Qin 2 tháng trước cách đây
mục cha
commit
77c7412271

+ 8 - 9
deps/db/src/logseq/db/frontend/content.cljs

@@ -113,12 +113,12 @@
                  :or {replace-tag? true}}]
   (assert (string? title))
   (let [refs' (->> refs
-                   (remove (fn [ref]
-                             ;; remove uuid references since they're introduced to detect multiple pages
-                             ;; that have the same name
-                             (and (map? ref)
-                                  (:block.temp/original-page-name ref)
-                                  (common-util/uuid-string? (:block.temp/original-page-name ref)))))
+                   (map (fn [ref]
+                          ;; remove uuid references since they're introduced to detect multiple pages
+                          ;; that have the same name
+                          (if (and (map? ref) (some-> (:block.temp/original-page-name ref) common-util/uuid-string?))
+                            (dissoc ref :block.temp/original-page-name)
+                            ref)))
                    (map
                     (fn [ref]
                       (if (and (vector? ref) (= :block/uuid (first ref)))
@@ -127,9 +127,8 @@
                         ref)))
                    sort-refs)]
     (reduce
-     (fn [content {uuid' :block/uuid :block/keys [title] :as block}]
-       (let [title' (or (:block.temp/original-page-name block) title)]
-         (replace-page-ref-with-id content title' uuid' replace-tag?)))
+     (fn [content {uuid' :block/uuid :block/keys [title]}]
+       (replace-page-ref-with-id content title uuid' replace-tag?))
      title
      (filter :block/title refs'))))
 

+ 2 - 1
deps/outliner/src/logseq/outliner/core.cljs

@@ -617,6 +617,7 @@
                      (when (:block/uuid target-block)
                        (d/entity db [:block/uuid (:block/uuid target-block)])))]
     (let [linked (:block/link block)
+          library? (ldb/library? block)
           up-down? (= outliner-op :move-blocks-up-down)
           [block sibling?] (cond
                              up-down?
@@ -648,7 +649,7 @@
                                  [last-child true]
                                  [block false])
                                :else
-                               [block sibling?])
+                               [block (if library? false sibling?)])
 
                              linked
                              (get-last-child-or-self db linked)

+ 2 - 2
src/main/frontend/handler/db_based/editor.cljs

@@ -64,10 +64,10 @@
                             (-> refs
                                 remove-non-existed-refs!
                                 (use-cached-refs! block))))))
+        title' (db-content/title-ref->id-ref (:block/title block) (:block/refs block))
         result (-> block
                    (merge (if level {:block/level level} {}))
-                   (assoc :block/title
-                          (db-content/title-ref->id-ref (:block/title block) (:block/refs block))))]
+                   (assoc :block/title title'))]
     result))
 
 (defn save-file!