Browse Source

fix(page): prevent checking existing page with custom ident namespace

charlie 1 month ago
parent
commit
513268edb3
1 changed files with 5 additions and 2 deletions
  1. 5 2
      deps/outliner/src/logseq/outliner/page.cljs

+ 5 - 2
deps/outliner/src/logseq/outliner/page.cljs

@@ -247,6 +247,7 @@
                (map (fn [id] (d/entity db [:block/uuid id])) tags)
                (map (fn [id] (d/entity db [:block/uuid id])) tags)
                tags)
                tags)
         class? (or class? (some (fn [t] (= :logseq.class/Tag (:db/ident t))) tags))
         class? (or class? (some (fn [t] (= :logseq.class/Tag (:db/ident t))) tags))
+        class-ident-namespace? (and class? class-ident-namespace (string? class-ident-namespace))
         title (sanitize-title title*)
         title (sanitize-title title*)
         types (cond class?
         types (cond class?
                     #{:logseq.class/Tag}
                     #{:logseq.class/Tag}
@@ -258,7 +259,9 @@
                     (set (map :db/ident tags))
                     (set (map :db/ident tags))
                     :else
                     :else
                     #{:logseq.class/Page})
                     #{:logseq.class/Page})
-        existing-page-id (first (ldb/page-exists? db title types))
+        ;; Check existing page only when not with custom ident namespace
+        existing-page-id (when (not class-ident-namespace?)
+                           (first (ldb/page-exists? db title types)))
         existing-page (some->> existing-page-id (d/entity db))]
         existing-page (some->> existing-page-id (d/entity db))]
     (if (and existing-page (not (:block/parent existing-page)))
     (if (and existing-page (not (:block/parent existing-page)))
       (let [tx-meta {:persist-op? persist-op?
       (let [tx-meta {:persist-op? persist-op?
@@ -269,7 +272,7 @@
           ;; Convert existing page to class
           ;; Convert existing page to class
           (let [tx-data [(merge (db-class/build-new-class db
           (let [tx-data [(merge (db-class/build-new-class db
                                                           (select-keys existing-page [:block/title :block/uuid :block/created-at])
                                                           (select-keys existing-page [:block/title :block/uuid :block/created-at])
-                                                          (when (and class? class-ident-namespace (string? class-ident-namespace))
+                                                          (when class-ident-namespace?
                                                             {:ident-namespace class-ident-namespace}))
                                                             {:ident-namespace class-ident-namespace}))
                                 (select-keys existing-page [:db/ident]))
                                 (select-keys existing-page [:db/ident]))
                          [:db/retract [:block/uuid (:block/uuid existing-page)] :block/tags :logseq.class/Page]]]
                          [:db/retract [:block/uuid (:block/uuid existing-page)] :block/tags :logseq.class/Page]]]