mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 15:39:50 -05:00
♻️ Try to fix recursive update-file ops on text edition
on concurrent multi-user sessions
This commit is contained in:
parent
a2cc7764fb
commit
d527184dfc
5 changed files with 16 additions and 50 deletions
|
@ -770,15 +770,6 @@
|
||||||
(update :undo-changes conj {:type :del-component
|
(update :undo-changes conj {:type :del-component
|
||||||
:id id
|
:id id
|
||||||
:main-instance main-instance})))
|
:main-instance main-instance})))
|
||||||
(defn ignore-remote
|
|
||||||
[changes]
|
|
||||||
(letfn [(add-ignore-remote
|
|
||||||
[change-list]
|
|
||||||
(->> change-list
|
|
||||||
(mapv #(assoc % :ignore-remote? true))))]
|
|
||||||
(-> changes
|
|
||||||
(update :redo-changes add-ignore-remote)
|
|
||||||
(update :undo-changes add-ignore-remote))))
|
|
||||||
|
|
||||||
(defn reorder-grid-children
|
(defn reorder-grid-children
|
||||||
[changes ids]
|
[changes ids]
|
||||||
|
|
|
@ -207,40 +207,16 @@
|
||||||
(-deref [_] {:changes changes})
|
(-deref [_] {:changes changes})
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ _ _]
|
||||||
(let [page-id (:current-page-id state)
|
;; The commit event is responsible to apply the data localy
|
||||||
|
;; and update the persistence internal state with the updated
|
||||||
position-data-operation?
|
;; file-revn
|
||||||
(fn [{:keys [type attr]}]
|
(rx/of (dch/commit {:file-id file-id
|
||||||
(and (= :set type)
|
:file-revn revn
|
||||||
(= attr :position-data)))
|
:save-undo? false
|
||||||
|
:source :remote
|
||||||
update-position-data
|
:redo-changes (vec changes)
|
||||||
(fn [change]
|
:undo-changes []})))))
|
||||||
;; Remove the position data from remote operations. Will be changed localy, otherwise
|
|
||||||
;; creates a strange "out-of-sync" behaviour.
|
|
||||||
(cond-> change
|
|
||||||
(and (= page-id (:page-id change))
|
|
||||||
(= :mod-obj (:type change)))
|
|
||||||
(update :operations #(d/removev position-data-operation? %))))
|
|
||||||
|
|
||||||
;; We update `position-data` from the incoming message
|
|
||||||
changes (->> changes
|
|
||||||
(map update-position-data)
|
|
||||||
(remove (fn [change]
|
|
||||||
(and (= page-id (:page-id change))
|
|
||||||
(:ignore-remote? change))))
|
|
||||||
(vec))]
|
|
||||||
|
|
||||||
;; The commit event is responsible to apply the data localy
|
|
||||||
;; and update the persistence internal state with the updated
|
|
||||||
;; file-revn
|
|
||||||
(rx/of (dch/commit {:file-id file-id
|
|
||||||
:file-revn revn
|
|
||||||
:save-undo? false
|
|
||||||
:source :remote
|
|
||||||
:redo-changes changes
|
|
||||||
:undo-changes []}))))))
|
|
||||||
|
|
||||||
(def ^:private
|
(def ^:private
|
||||||
schema:handle-library-change
|
schema:handle-library-change
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
|
|
||||||
(defn update-shapes
|
(defn update-shapes
|
||||||
([ids update-fn] (update-shapes ids update-fn nil))
|
([ids update-fn] (update-shapes ids update-fn nil))
|
||||||
([ids update-fn {:keys [reg-objects? save-undo? stack-undo? attrs ignore-tree page-id ignore-remote? ignore-touched undo-group with-objects?]
|
([ids update-fn {:keys [reg-objects? save-undo? stack-undo? attrs ignore-tree page-id ignore-touched undo-group with-objects?]
|
||||||
:or {reg-objects? false save-undo? true stack-undo? false ignore-remote? false ignore-touched false with-objects? false}}]
|
:or {reg-objects? false save-undo? true stack-undo? false ignore-touched false with-objects? false}}]
|
||||||
|
|
||||||
(dm/assert!
|
(dm/assert!
|
||||||
"expected a valid coll of uuid's"
|
"expected a valid coll of uuid's"
|
||||||
|
@ -84,8 +84,7 @@
|
||||||
changes (add-undo-group changes state)]
|
changes (add-undo-group changes state)]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(if (seq (:redo-changes changes))
|
(if (seq (:redo-changes changes))
|
||||||
(let [changes (cond-> changes reg-objects? (pcb/resize-parents ids))
|
(let [changes (cond-> changes reg-objects? (pcb/resize-parents ids))]
|
||||||
changes (cond-> changes ignore-remote? (pcb/ignore-remote))]
|
|
||||||
(rx/of (dch/commit-changes changes)))
|
(rx/of (dch/commit-changes changes)))
|
||||||
(rx/empty))
|
(rx/empty))
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,6 @@
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dwsh/update-shapes ids update-fn {:reg-objects? true
|
(dwsh/update-shapes ids update-fn {:reg-objects? true
|
||||||
:stack-undo? true
|
:stack-undo? true
|
||||||
:ignore-remote? true
|
|
||||||
:ignore-touched true})
|
:ignore-touched true})
|
||||||
(ptk/data-event :layout/update {:ids ids})
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))))
|
(dwu/commit-undo-transaction undo-id))))))))
|
||||||
|
@ -536,7 +535,7 @@
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
(-> shape
|
(-> shape
|
||||||
(assoc :position-data (get position-data (:id shape)))))
|
(assoc :position-data (get position-data (:id shape)))))
|
||||||
{:stack-undo? true :reg-objects? false :ignore-remote? true}))
|
{:stack-undo? true :reg-objects? false}))
|
||||||
(rx/of (fn [state]
|
(rx/of (fn [state]
|
||||||
(dissoc state ::update-position-data-debounce ::update-position-data))))))))
|
(dissoc state ::update-position-data-debounce ::update-position-data))))))))
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(defn fix-position [shape]
|
(defn fix-position
|
||||||
|
[shape]
|
||||||
(if-let [modifiers (:modifiers shape)]
|
(if-let [modifiers (:modifiers shape)]
|
||||||
(let [shape' (gsh/transform-shape shape modifiers)
|
(let [shape' (gsh/transform-shape shape modifiers)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue