🐛 Fix sometimes sync of adding/removing shapes fails

This commit is contained in:
Pablo Alba 2023-12-05 14:38:09 +01:00
parent fa90403d84
commit 6a5d9402d5

View file

@ -1070,13 +1070,18 @@
(= ::watch-component-changes (ptk/type %))))) (= ::watch-component-changes (ptk/type %)))))
workspace-data-s workspace-data-s
(->> (rx/from-atom refs/workspace-data {:emit-current-value? true})
(rx/share))
workspace-buffer-s
(->> (rx/concat (->> (rx/concat
(rx/of nil) (rx/take 1 workspace-data-s)
(rx/from-atom refs/workspace-data {:emit-current-value? true})) (rx/take 1 workspace-data-s)
;; Need to get the file data before the change, so deleted shapes workspace-data-s)
;; still exist, for example ;; Need to get the file data before the change, so deleted shapes
(rx/buffer 3 1) ;; still exist, for example. We initialize the buffer with three
(rx/filter (fn [[old-data]] (some? old-data)))) ;; copies of the initial state
(rx/buffer 3 1))
changes-s changes-s
(->> stream (->> stream
@ -1106,7 +1111,7 @@
changes-s changes-s
(->> changes-s (->> changes-s
(rx/with-latest-from workspace-data-s) (rx/with-latest-from workspace-buffer-s)
(rx/mapcat check-changes) (rx/mapcat check-changes)
(rx/share)) (rx/share))