Browse Source

fix: tests and warnings

Tienson Qin 1 year ago
parent
commit
54d2cd6a0d

+ 3 - 3
deps/db/src/logseq/db.cljs

@@ -47,13 +47,13 @@
 
 (defn start-conn
   "Create datascript conn with schema and default data"
-  [& {:keys [create-default-pages? schema]
+  [& {:keys [create-default-pages? schema file-based?]
       :or {create-default-pages? true
            schema db-schema/schema}}]
   (let [db-conn (d/create-conn schema)
-        db-based? (= schema db-schema/schema)]
+        file-based? (or (= schema db-schema/schema) file-based?)]
     (when create-default-pages?
       (create-default-pages! db-conn {}))
-    (when db-based?
+    (when-not file-based?
       (create-built-in-properties! db-conn))
     db-conn))

+ 1 - 1
deps/db/src/logseq/db/frontend/schema.cljs

@@ -122,7 +122,7 @@
 (def schema-for-db-based-graph
   (merge
    (dissoc schema
-           :block/properties-text-values :block/pre-block? :recent/pages :file/handle :block/file
+           :block/properties-text-values :block/pre-block? :recent/pages :file/handle
            :block/properties-order)
    {:file/last-modified-at {}}))
 

+ 1 - 1
deps/graph-parser/src/logseq/graph_parser/cli.cljs

@@ -75,7 +75,7 @@
   ([dir options]
    (let [config (read-config dir)
          files (or (:files options) (build-graph-files dir config))
-         conn (or (:conn options) (ldb/start-conn))
+         conn (or (:conn options) (ldb/start-conn {:file-based? true}))
          _ (when-not (:files options) (println "Parsing" (count files) "files..."))
          asts (parse-files conn files (merge options {:config config}))]
      {:conn conn

+ 1 - 1
src/main/frontend/components/block.cljs

@@ -537,7 +537,7 @@
              (state/get-left-sidebar-open?))
     (ui-handler/close-left-sidebar!)))
 
-(rum/defcs page-inner <
+(rum/defcs ^:large-vars/cleanup-todo page-inner <
   (rum/local false ::mouse-down?)
   (rum/local false ::hover?)
   "The inner div of page reference component

+ 12 - 1
src/main/frontend/handler/events.cljs

@@ -52,6 +52,7 @@
             [frontend.handler.user :as user-handler]
             [frontend.handler.property.util :as pu]
             [frontend.handler.db-based.property.util :as db-pu]
+            [frontend.handler.file-based.property.util :as property-util]
             [frontend.handler.property :as property-handler]
             [frontend.handler.whiteboard :as whiteboard-handler]
             [frontend.handler.web.nfs :as nfs-handler]
@@ -809,7 +810,17 @@
     :label "graph-setup"}))
 
 (defmethod handle :search/transact-data [[_ repo data]]
-  (search/transact-blocks! repo data))
+  (let [file-based? (config/local-file-based-graph? repo)
+        data' (cond-> data
+                file-based?
+                        ;; remove built-in properties from content
+                (update :blocks-to-add
+                        (fn [blocks]
+                          (map #(update % :content
+                                        (fn [content]
+                                          (property-util/remove-built-in-properties (get % :format :markdown) content)))
+                               blocks))))]
+    (search/transact-blocks! repo data')))
 
 (defmethod handle :class/configure [[_ page]]
   (state/set-modal!

+ 1 - 1
src/main/frontend/modules/outliner/datascript.cljs

@@ -48,7 +48,7 @@
       (when fail-invalid? (js/alert "Invalid DB!")))))
 
 (defn after-transact-pipelines
-  [repo {:keys [_db-before _db-after _tx-data _tempids tx-meta] :as tx-report}]
+  [_repo {:keys [_db-before _db-after _tx-data _tempids tx-meta] :as tx-report}]
   (when-not config/test?
     (pipelines/invoke-hooks tx-report)
     (when (and config/dev?

+ 2 - 13
src/main/frontend/persist_db/browser.cljs

@@ -10,8 +10,7 @@
             [frontend.handler.notification :as notification]
             [cljs-bean.core :as bean]
             [frontend.state :as state]
-            [electron.ipc :as ipc]
-            [frontend.handler.file-based.property.util :as property-util]))
+            [electron.ipc :as ipc]))
 
 (defonce *sqlite (atom nil))
 
@@ -85,17 +84,7 @@
        (ipc/ipc :db-transact repo tx-data' tx-meta')
        (if sqlite
          (p/let [result (.transact sqlite repo tx-data' tx-meta')
-                 result' (bean/->clj result)
-                 file-based? (config/local-file-based-graph? repo)
-                 data (cond-> result'
-                        file-based?
-                        ;; remove built-in properties from content
-                        (update :blocks-to-add
-                                (fn [blocks]
-                                  (map #(update % :content
-                                               (fn [content]
-                                                 (property-util/remove-built-in-properties (get % :format :markdown) content)))
-                                    blocks))))]
+                 data (bean/->clj result)]
            (state/pub-event! [:search/transact-data repo data])
            nil)
          (notification/show! "Latest change was not saved! Please restart the application." :error))

+ 0 - 1
src/main/frontend/search.cljs

@@ -14,7 +14,6 @@
             [frontend.config :as config]
             [logseq.db.frontend.property :as db-property]
             [frontend.handler.file-based.property.util :as property-util]
-            [frontend.db.model :as db-model]
             [cljs-bean.core :as bean]))
 
 (def fuzzy-search fuzzy/fuzzy-search)

+ 7 - 5
src/main/frontend/state.cljs

@@ -970,11 +970,13 @@ Similar to re-frame subscriptions"
    (when-let [node @*editor-editing-ref]
      (some-> (dom/sel1 node "textarea")
              (gobj/get "id")))
-   (when-let [elem js/document.activeElement]
-     (when (util/input? elem)
-       (let [id (gobj/get elem "id")]
-         (when (string/starts-with? id "edit-block-")
-           id))))))
+   (try
+     (when-let [elem js/document.activeElement]
+      (when (util/input? elem)
+        (let [id (gobj/get elem "id")]
+          (when (string/starts-with? id "edit-block-")
+            id))))
+     (catch :default _e))))
 
 (defn get-input
   []

+ 1 - 2
src/test/frontend/db/model_test.cljs

@@ -4,8 +4,7 @@
             [frontend.db :as db]
             [frontend.db.conn :as conn]
             [frontend.test.helper :as test-helper :refer [load-test-files]]
-            [datascript.core :as d]
-            [clojure.set :as set]))
+            [datascript.core :as d]))
 
 (use-fixtures :each {:before test-helper/start-test-db!
                      :after test-helper/destroy-test-db!})