From 91a05c0c7d78898a546d923ed430f48c7d6ba365 Mon Sep 17 00:00:00 2001 From: Tony Kay Date: Tue, 3 Oct 2023 10:03:19 -0700 Subject: [PATCH] Refactored uses of registry keys to accept all legal registry key types. --- .../com/fulcrologic/fulcro/mutations.cljc | 20 +++++++++---------- .../fulcro/offline/durable_mutations.cljc | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/com/fulcrologic/fulcro/mutations.cljc b/src/main/com/fulcrologic/fulcro/mutations.cljc index 3daf0a3f..dfc8f6f2 100644 --- a/src/main/com/fulcrologic/fulcro/mutations.cljc +++ b/src/main/com/fulcrologic/fulcro/mutations.cljc @@ -129,7 +129,7 @@ remote-error? (ah/app-algorithm app :remote-error?) {:keys [dispatch-key]} transmitted-ast return-value (when dispatch-key (get-in result [:body dispatch-key])) - env (assoc env :mutation-return-value return-value)] + env (assoc env :mutation-return-value return-value)] (if (remote-error? result) (when error-action (error-action env)) @@ -342,17 +342,15 @@ (returning env class nil)) ([env class {:keys [query-params] :as opts}] - (let [class (if (or (keyword? class) (symbol? class)) - (rc/registry-key->class class) - class)] + (let [class (rc/registry-key->class class)] (let [{:keys [state ast]} env - {:keys [key params query]} ast] - (let [component-query (rc/get-query class @state) - updated-query (cond-> (eql/query->ast component-query) - query-params (update-in [:children 0] assoc :params query-params) - :then (eql/ast->query) - query (vary-meta #(merge (meta query) %)))] - (assoc env :ast (eql/query->ast1 [{(list key params) updated-query}]))))))) + {:keys [key params query]} ast + component-query (rc/get-query class @state) + updated-query (cond-> (eql/query->ast component-query) + query-params (update-in [:children 0] assoc :params query-params) + :then (eql/ast->query) + query (vary-meta #(merge (meta query) %)))] + (assoc env :ast (eql/query->ast1 [{(list key params) updated-query}])))))) diff --git a/src/main/com/fulcrologic/fulcro/offline/durable_mutations.cljc b/src/main/com/fulcrologic/fulcro/offline/durable_mutations.cljc index 64631c55..8e0fdfc5 100644 --- a/src/main/com/fulcrologic/fulcro/offline/durable_mutations.cljc +++ b/src/main/com/fulcrologic/fulcro/offline/durable_mutations.cljc @@ -153,7 +153,7 @@ last-time (or last-attempt 0) n (min attempt 1000) delay (min backoff-limit-ms (* n n 1000)) - options (if (keyword? (:component options)) + options (if (rc/legal-registry-lookup-key? (:component options)) (update options :component rc/registry-key->class) options)] (if (or (= 0 attempt) (> (- now last-time) delay)) @@ -234,7 +234,7 @@ [app mutation-store tempid-strategy] (let [app (-> app (update :com.fulcrologic.fulcro.application/config merge {::mutation-store mutation-store - ::tempid-strategy tempid-strategy}) + ::tempid-strategy tempid-strategy}) (with-augmented-result-action) (with-durable-transact))] (transaction-loop! app)