Răsfoiți Sursa

perf: disable new-db cache for custom queries

related to #4285
Tienson Qin 4 ani în urmă
părinte
comite
db07341ebe
1 a modificat fișierele cu 19 adăugiri și 18 ștergeri
  1. 19 18
      src/main/frontend/db/react.cljs

+ 19 - 18
src/main/frontend/db/react.cljs

@@ -157,24 +157,25 @@
 
 (defn- new-db
   [cached-result tx-data old-db k]
-  (try
-    (let [empty-db (d/empty-db db-schema/schema)
-          db (or old-db
-                 (when (and (coll? cached-result)
-                            (or (map? (first cached-result))
-                                (empty? cached-result)))
-                   (let [cached-result (util/remove-nils cached-result)]
-                     (-> empty-db
-                         (d/with cached-result)
-                         (:db-after)))))]
-      (when db
-        (:db-after (d/with db tx-data))))
-    (catch js/Error e
-      (prn "New db: " {:k k
-                       :old-db old-db
-                       :cached-result cached-result})
-      (js/console.error e)
-      old-db)))
+  (when-not (= :custom (second k))
+    (try
+      (let [empty-db (d/empty-db db-schema/schema)
+            db (or old-db
+                   (when (and (coll? cached-result)
+                              (or (map? (first cached-result))
+                                  (empty? cached-result)))
+                     (let [cached-result (util/remove-nils cached-result)]
+                       (-> empty-db
+                           (d/with cached-result)
+                           (:db-after)))))]
+        (when db
+          (:db-after (d/with db tx-data))))
+      (catch js/Error e
+        (prn "New db: " {:k k
+                         :old-db old-db
+                         :cached-result cached-result})
+        (js/console.error e)
+        old-db))))
 
 (defn get-query-cached-result
   [k]