Tienson Qin 3 lat temu
rodzic
commit
5d17315561

+ 1 - 7
src/main/frontend/components/search.cljs

@@ -310,14 +310,8 @@
   [state]
   (let [search-result (state/sub :search/result)
         search-q (state/sub :search/q)
-        blocks-count (or (db/blocks-count) 0)
         search-mode (state/sub :search/mode)
-        timeout (cond
-                  (> blocks-count 2000)
-                  400
-
-                  :else
-                  300)
+        timeout 300
         in-page-search? (= search-mode :page)]
     (rum/with-context [[t] i18n/*tongue-context*]
       [:div.cp__palette.cp__palette-main

+ 0 - 12
src/main/frontend/db/model.cljs

@@ -665,18 +665,6 @@
           block-uuid)
         (sort-by-left (db-utils/entity [:block/uuid block-uuid])))))
 
-(defn get-blocks-by-page
-  [repo id-or-lookup-ref]
-  (when-let [conn (conn/get-conn repo)]
-    (->
-     (d/q
-      '[:find (pull ?block [*])
-        :in $ ?page
-        :where
-        [?block :block/page ?page]]
-      conn id-or-lookup-ref)
-     flatten)))
-
 (defn get-block-children
   "Including nested children."
   [repo block-uuid]

+ 1 - 0
src/main/frontend/db/react.cljs

@@ -296,6 +296,7 @@
            distinct)))
       [[key]])))
 
+;; TODO: incremental or delayed queries (e.g. only run custom queries when idle)
 (defn refresh!
   [repo-url handler-opts]
   (let [related-keys (get-related-keys handler-opts)

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

@@ -3120,8 +3120,7 @@
   [block id search-timeout]
   (fn [e]
     (if (state/sub :editor/show-block-search?)
-      (let [blocks-count (or (db/blocks-count) 0)
-            timeout (if (> blocks-count 2000) 300 100)]
+      (let [timeout 300]
         (when @search-timeout
           (js/clearTimeout @search-timeout))
         (reset! search-timeout

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

@@ -25,7 +25,7 @@
   [repo page-db-id]
   (let [page-block (db/pull repo '[*] page-db-id)
         page-db-id (:db/id page-block)
-        blocks (model/get-blocks-by-page repo page-db-id)]
+        blocks (model/get-page-blocks-no-cache repo (:block/name page-block))]
     (when-not (and (= 1 (count blocks))
                    (string/blank? (:block/content (first blocks)))
                    (nil? (:block/file page-block)))