From 647e7e4584729a26a270dfc3dde1f07bbd3b5192 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 19 Mar 2025 18:02:41 +0800 Subject: [PATCH] add lru cache for > (for [item items] (rum/with-key (select-item property type item opts) (or (:block/uuid item) (str item)))) - (interpose [:span.opacity-50.-ml-2 ","])) + (interpose [:span.opacity-50.-ml-1 ","])) (when date? [(property-value-date-picker block property nil {:toggle-fn toggle-fn})])) (if date? diff --git a/src/main/frontend/components/views.cljs b/src/main/frontend/components/views.cljs index 0a7afcde7d..c3f2a9cad9 100644 --- a/src/main/frontend/components/views.cljs +++ b/src/main/frontend/components/views.cljs @@ -1089,16 +1089,15 @@ [idx {:keys [full-block-ids properties]} item-render] (let [db-id (util/nth-safe full-block-ids idx) block (db/entity db-id) - [item set-item!] (hooks/use-state block)] + [item set-item!] (hooks/use-state block) + opts {:children? false + :properties properties + :skip-transact? true + :skip-refresh? true}] (hooks/use-effect! (fn [] - (when (and db-id (not (:block.temp/fully-loaded? block))) - (p/let [result (db-async/ (:db/id block) db/entity))))))) [db-id]) diff --git a/src/main/frontend/db/async.cljs b/src/main/frontend/db/async.cljs index 495d512dcc..b1bec03c54 100644 --- a/src/main/frontend/db/async.cljs +++ b/src/main/frontend/db/async.cljs @@ -3,6 +3,7 @@ (:require [cljs-time.coerce :as tc] [cljs-time.core :as t] [cljs-time.format :as tf] + [cljs.cache :as cache] [datascript.core :as d] [frontend.config :as config] [frontend.date :as date] @@ -110,36 +111,44 @@ (cons default-value-id result) result))))) +(defonce *block-cache (atom (cache/lru-cache-factory {} :threshold 1000))) (defn