瀏覽代碼

fix: file graphs can't load b/c db specific attribute fetched

Gabriel Horner 1 年之前
父節點
當前提交
5c81b61774
共有 2 個文件被更改,包括 9 次插入6 次删除
  1. 1 0
      .clj-kondo/config.edn
  2. 8 6
      deps/db/src/logseq/db/sqlite/common_db.cljs

+ 1 - 0
.clj-kondo/config.edn

@@ -139,6 +139,7 @@
              logseq.db ldb
              logseq.db.frontend.content db-content
              logseq.db.frontend.inputs db-inputs
+             logseq.db.frontend.order db-order
              logseq.db.frontend.property db-property
              logseq.db.frontend.property.build db-property-build
              logseq.db.frontend.property.type db-property-type

+ 8 - 6
deps/db/src/logseq/db/sqlite/common_db.cljs

@@ -231,19 +231,21 @@
                       children)))))
 
 (defn get-initial-data
-  "Returns current database schema and initial data"
+  "Returns current database schema and initial data.
+   NOTE: This fn is called by DB and file graphs"
   [db]
-  (let [max-key (db-order/get-max-order db)]
-    (db-order/reset-max-key! max-key))
-  (let [schema (:schema db)
+  (let [db-graph? (entity-plus/db-based-graph? db)
+        _ (when db-graph?
+            (db-order/reset-max-key! (db-order/get-max-order db)))
+        schema (:schema db)
         idents (mapcat (fn [id]
                          (when-let [e (d/entity db id)]
                            (d/datoms db :eavt (:db/id e))))
                        [:logseq.kv/db-type :logseq.kv/graph-uuid])
-        favorites (get-favorites db)
+        favorites (when db-graph? (get-favorites db))
         latest-journals (get-latest-journals db 3)
         all-files (get-all-files db)
-        structured-datoms (when (entity-plus/db-based-graph? db)
+        structured-datoms (when db-graph?
                             (get-structured-datoms db))
         data (concat idents
                      structured-datoms