Sfoglia il codice sorgente

fix: zoom into block

Tienson Qin 1 anno fa
parent
commit
4a63f78aa8

+ 5 - 4
deps/db/src/logseq/db.cljs

@@ -400,10 +400,11 @@
 (defn get-page
   "Get a page given its unsanitized name"
   [db page-name-or-uuid]
-  (if-let [id (if (uuid? page-name-or-uuid) page-name-or-uuid
-                  (parse-uuid page-name-or-uuid))]
-    (d/entity db [:block/uuid id])
-    (d/entity db (get-first-page-by-name db (name page-name-or-uuid)))))
+  (when db
+    (if-let [id (if (uuid? page-name-or-uuid) page-name-or-uuid
+                    (parse-uuid page-name-or-uuid))]
+      (d/entity db [:block/uuid id])
+      (d/entity db (get-first-page-by-name db (name page-name-or-uuid))))))
 
 (defn get-page-alias
   [db page-id]

+ 2 - 1
deps/db/src/logseq/db/sqlite/common_db.cljs

@@ -15,7 +15,8 @@
 (defn get-first-page-by-name
   "Return the oldest page's db id"
   [db page-name]
-  (first (sort (map :e (get-pages-by-name db page-name)))))
+  (when (and db (string? page-name))
+    (first (sort (map :e (get-pages-by-name db page-name))))))
 
 (comment
   (defn- get-built-in-files

+ 4 - 4
src/main/frontend/db_worker.cljs

@@ -327,10 +327,10 @@
 
   (get-block-and-children
    [_this repo id-str children?]
-   (assert (common-util/uuid-string? id-str))
-   (when-let [conn (worker-state/get-datascript-conn repo)]
-     (let [id (uuid id-str)]
-       (ldb/write-transit-str (sqlite-common-db/get-block-and-children @conn id children?)))))
+   (when (common-util/uuid-string? id-str)
+     (when-let [conn (worker-state/get-datascript-conn repo)]
+       (let [id (uuid id-str)]
+         (ldb/write-transit-str (sqlite-common-db/get-block-and-children @conn id children?))))))
 
   (get-block-refs
    [_this repo id]