From e6d6b60b63e4a8fd9610ea604e99a2f31fe74a7f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 14 Mar 2022 12:39:37 +0100 Subject: [PATCH] :bug: Properly filter complex data on events payload --- frontend/src/app/main/data/events.cljs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/data/events.cljs b/frontend/src/app/main/data/events.cljs index 5104d39fc..d6696bffe 100644 --- a/frontend/src/app/main/data/events.cljs +++ b/frontend/src/app/main/data/events.cljs @@ -133,6 +133,19 @@ (dissoc ::context) (cond-> origin (assoc :origin origin)))})))) +(defn- filter-props + "Removes complex data types from props." + [data] + (into {} + (map (fn [[k v :as kv]] + (cond + (map? v) [k :placeholder/map] + (vector? v) [k :placeholder/vec] + (set? v) [k :placeholder/set] + (coll? v) [k :placeholder/coll] + :else kv))) + data)) + (defmethod process-event ::generic-action [event] (let [type (ptk/type event) @@ -143,8 +156,9 @@ {:type "action" :name (or (::name mdata) (name type)) - :props (merge (d/without-nils data) - (d/without-nils (::props mdata))) + :props (-> (merge (d/without-nils data) + (d/without-nils (::props mdata))) + (filter-props)) :context (d/without-nils {:event-origin (::origin mdata) :event-namespace (namespace type)