This commit is contained in:
alonso.torres 2026-04-16 12:04:50 +02:00
parent fbfc093f3e
commit 9fa72fb25b
5 changed files with 35 additions and 10 deletions

View File

@ -669,7 +669,7 @@
[modif-tree & {:keys [ignore-constraints ignore-snap-pixel snap-ignore-axis undo-transation?]
:or {ignore-constraints false ignore-snap-pixel false snap-ignore-axis nil undo-transation? true}
:as params}]
(ptk/reify ::apply-wasm-modifiesr
(ptk/reify ::apply-wasm-modifiers
ptk/WatchEvent
(watch [_ state _]
(wasm.api/clean-modifiers)

View File

@ -119,6 +119,8 @@
:undo-group undo-group}))))
(rx/empty))))))
(defonce layout-pending (atom false))
(defn initialize-shape-layout
[]
(ptk/reify ::initialize-shape-layout
@ -129,10 +131,12 @@
;; FIXME: we don't need use types for simple signaling,
;; we can just use a keyword for it
(rx/filter (ptk/type? :layout/update))
(rx/tap #(reset! layout-pending true))
(rx/map deref)
;; We buffer the updates to the layout so if there are many changes at the same time
;; they are process together. It will get a better performance.
(rx/buffer-time 100)
(rx/tap #(reset! layout-pending false))
(rx/filter #(d/not-empty? %))
(rx/mapcat
(fn [data]

View File

@ -121,6 +121,8 @@
:else
(rx/empty)))))))
(def resize-pending (atom false))
;; This event will debounce the resize events so, if there are many, they
;; are processed at the same time and not one-by-one. This will improve
;; performance because it's better to make only one layout calculation instead
@ -146,8 +148,10 @@
(rx/merge
(->> stream
(rx/filter (ptk/type? ::resize-wasm-text-debounce-inner))
(rx/tap #(reset! resize-pending true))
(rx/debounce debounce-resize-text-time)
(rx/take 1)
(rx/tap #(reset! resize-pending false))
(rx/map (fn [evt]
(resize-wasm-text-debounce-commit
(some-> evt meta :undo-group)

View File

@ -27,7 +27,9 @@
[app.main.data.workspace.colors :as dwc]
[app.main.data.workspace.groups :as dwg]
[app.main.data.workspace.media :as dwm]
[app.main.data.workspace.modifiers :as dwmm]
[app.main.data.workspace.selection :as dws]
[app.main.data.workspace.shape-layout :as dwsl]
[app.main.data.workspace.variants :as dwv]
[app.main.data.workspace.wasm-text :as dwwt]
[app.main.features :as features]
@ -660,14 +662,30 @@
(fn [timeout]
(js/Promise.
(fn [resolve reject]
(->> (rx/combine-latest-all
[(if timeout
(->> (rx/of :timeout)
(rx/delay timeout))
(rx/empty))
(->> (rx/merge
(if timeout
(->> (rx/of :timeout)
(rx/delay timeout))
(rx/empty))
;; TODO: Wait for the layout to update
])
;; Estas dos operaciones seria "take last" y luego tambien esta que
;; hay que ver lo de la fuente.
(if @dwsl/layout-pending
(->> st/stream
(rx/filter (ptk/type? ::dwsl/update-layout-positions))
(rx/take 1))
(rx/empty))
(if @dwwt/resize-pending
(->> st/stream
(rx/filter (ptk/type? ::dwmm/apply-wasm-modifiers))
(rx/take 1))
(rx/empty))
(if (and (not @dwwt/resize-pending)
(not @dwsl/layout-pending))
(rx/of :ok)
(rx/empty)))
(rx/take 1)
(rx/subs!
(fn [value]

View File

@ -25,8 +25,7 @@
[app.plugins.utils :as u]
[app.util.object :as obj]
[app.util.text-editor :as ted]
[cuerdas.core :as str]
[potok.v2.core :as ptk]))
[cuerdas.core :as str]))
;; This regex seems duplicated but probably in the future when we support diferent units
;; this will need to reflect changes for each property