0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

🐛 Properly filter complex data on events payload

This commit is contained in:
Andrey Antukh 2022-03-14 12:39:37 +01:00
parent 70beb6c60c
commit e6d6b60b63

View file

@ -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)
: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)