🐛 Fix parsing pending callback on setting single shape attr

This commit is contained in:
Elena Torro 2025-06-10 21:34:41 +02:00
parent f02dd9f8dc
commit 330bee7839

View file

@ -6,6 +6,7 @@
(ns app.render-wasm.shape
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.transit :as t]
[app.common.types.shape :as shape]
@ -206,12 +207,13 @@
(defn set-wasm-multi-attrs!
[shape properties]
(api/use-shape (:id shape))
(let [pending
(let [result
(->> properties
(mapcat #(set-wasm-single-attr! shape %)))]
(mapcat #(set-wasm-single-attr! shape %)))
pending (-> (d/index-by :key :callback result) vals)]
(if (and pending (seq pending))
(->> (rx/from pending)
(rx/mapcat identity)
(rx/mapcat (fn [callback] (callback)))
(rx/reduce conj [])
(rx/subs!
(fn [_]
@ -226,11 +228,12 @@
[shape k v]
(let [shape (assoc shape k v)]
(api/use-shape (:id shape))
(let [pending (set-wasm-single-attr! shape k)]
(let [result (set-wasm-single-attr! shape k)
pending (-> (d/index-by :key :callback result) vals)]
;; TODO: set-wasm-attrs is called twice with every set
(if (and pending (seq pending))
(->> (rx/from pending)
(rx/mapcat identity)
(rx/mapcat (fn [callback] (callback)))
(rx/reduce conj [])
(rx/subs!
(fn [_]