🐛 Fix problem in wasm when duplicate objects

This commit is contained in:
alonso.torres 2025-05-30 13:43:10 +02:00
parent ad842872fb
commit e8d1ea24d1

View file

@ -274,6 +274,14 @@
(rx/map bundle-fetched) (rx/map bundle-fetched)
(rx/take-until stopper-s)))))) (rx/take-until stopper-s))))))
(defn process-wasm-object
[id]
(ptk/reify ::process-wasm-object
ptk/EffectEvent
(effect [_ state _]
(let [objects (dsh/lookup-page-objects state)]
(api/process-object (get objects id))))))
(defn initialize-workspace (defn initialize-workspace
[team-id file-id] [team-id file-id]
(assert (uuid? team-id) "expected valud uuid for `team-id`") (assert (uuid? team-id) "expected valud uuid for `team-id`")
@ -361,24 +369,30 @@
(rx/take 1) (rx/take 1)
(rx/map #(dwcm/navigate-to-comment-id comment-id)))) (rx/map #(dwcm/navigate-to-comment-id comment-id))))
(when render-wasm?
(->> stream
(rx/filter dch/commit?)
(rx/map deref)
(rx/mapcat
(fn [{:keys [redo-changes]}]
(let [added (->> redo-changes
(filter #(= (:type %) :add-obj))
(map :id))]
(->> (rx/from added)
(rx/map process-wasm-object)))))))
(->> stream (->> stream
(rx/filter dch/commit?) (rx/filter dch/commit?)
(rx/map deref) (rx/map deref)
(rx/mapcat (fn [{:keys [save-undo? undo-changes redo-changes undo-group tags stack-undo?]}] (rx/mapcat
(when render-wasm? (fn [{:keys [save-undo? undo-changes redo-changes undo-group tags stack-undo?]}]
(let [added (->> redo-changes (if (and save-undo? (seq undo-changes))
(filter #(= (:type %) :add-obj)) (let [entry {:undo-changes undo-changes
(map :obj))] :redo-changes redo-changes
(doseq [shape added] :undo-group undo-group
(api/process-object shape)))) :tags tags}]
(rx/of (dwu/append-undo entry stack-undo?)))
(if (and save-undo? (seq undo-changes)) (rx/empty))))))
(let [entry {:undo-changes undo-changes
:redo-changes redo-changes
:undo-group undo-group
:tags tags}]
(rx/of (dwu/append-undo entry stack-undo?)))
(rx/empty))))))
(rx/take-until stoper-s)))) (rx/take-until stoper-s))))
ptk/EffectEvent ptk/EffectEvent