Should improve perf somewhat

This commit is contained in:
Bryce Covert
2020-05-02 08:09:26 -07:00
parent 532e35bb50
commit 5643b98b13
6 changed files with 116 additions and 91 deletions

View File

@@ -48,34 +48,41 @@
(fn [db]
(-> db ::transaction-page)))
(re-frame/reg-sub
::last-params
(fn [db]
(::last-params db)))
(re-frame/reg-sub
::params
:<- [::last-params]
:<- [::subs/client]
:<- [::side-bar/filter-params]
:<- [::table/table-params]
(fn [[client filter-params table-params]]
(re-frame/dispatch [::params-change])
(cond-> {}
client (assoc :client-id (:id client))
(seq filter-params) (merge filter-params)
(seq table-params) (merge @(re-frame/subscribe [::table/table-params])))))
(fn [[last-params client filter-params table-params]]
(let [params (cond-> {}
client (assoc :client-id (:id client))
(seq filter-params) (merge filter-params)
(seq table-params) (merge table-params))]
(when (not= last-params params)
(re-frame/dispatch [::params-change]))
params)))
(re-frame/reg-event-fx
::params-change
[with-user (re-frame/inject-cofx ::inject/sub [::params])]
(fn [{:keys [user db ] ::keys [params]} _]
(when (not= (::last-params db) params)
{:db (-> db
(assoc-in [:status :loading] true)
(assoc-in [::last-params] params))
:graphql {:token user
:query-obj {:venia/queries [[:transaction_page
params
[[:transactions transaction-read]
:total
:start
:end]]]}
:on-success [::received]}})))
{:db (-> db
(assoc-in [:status :loading] true)
(assoc-in [::last-params] params))
:graphql {:token user
:query-obj {:venia/queries [[:transaction_page
params
[[:transactions transaction-read]
:total
:start
:end]]]}
:on-success [::received]}}))
(re-frame/reg-event-fx
::unapprove-all
@@ -148,7 +155,6 @@
(defn transactions-page [{:keys [approval-status]}]
(reagent/create-class
{:display-name "transaction-page"
:component-did-mount #(re-frame/dispatch [::params-change {}])
:component-will-unmount #(re-frame/dispatch [::unmounted])
:reagent-render
(fn []