diff --git a/CHANGES.md b/CHANGES.md index 7e3de720b9..6fcf5d7aa9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -43,6 +43,7 @@ - Fix components marked as touched when moved [Taiga #4061](https://tree.taiga.io/project/penpot/task/4061) - Fix boards grouped shouldn't show the title [Taiga #4251](https://tree.taiga.io/project/penpot/issue/4251) - Fix gradient handlers are under resize handlers[Taiga #4298](https://tree.taiga.io/project/penpot/issue/4298) +- Fix grid not syncing immediately in multiuser [Taiga #4339](https://tree.taiga.io/project/penpot/issue/4339) ### :arrow_up: Deps updates ### :heart: Community contributions by (Thank you!) diff --git a/frontend/src/app/main/data/workspace/persistence.cljs b/frontend/src/app/main/data/workspace/persistence.cljs index 62ea1c2245..ba00a8777d 100644 --- a/frontend/src/app/main/data/workspace/persistence.cljs +++ b/frontend/src/app/main/data/workspace/persistence.cljs @@ -12,6 +12,7 @@ [app.common.pages.changes-spec :as pcs] [app.common.spec :as us] [app.common.types.file :as ctf] + [app.common.types.shape-tree :as ctst] [app.common.uuid :as uuid] [app.config :as cf] [app.main.data.dashboard :as dd] @@ -219,14 +220,23 @@ (ptk/reify ::changes-persisted ptk/UpdateEvent (update [_ state] - (if (= file-id (:current-file-id state)) - (-> state - (update-in [:workspace-file :revn] max revn) - (update :workspace-data cp/process-changes changes)) - (-> state - (update-in [:workspace-libraries file-id :revn] max revn) - (update-in [:workspace-libraries file-id :data] - cp/process-changes changes)))))) + (let [changes (group-by :page-id changes)] + (if (= file-id (:current-file-id state)) + (-> state + (update-in [:workspace-file :revn] max revn) + (update :workspace-data (fn [file] + (loop [fdata file + entries (seq changes)] + (if-let [[page-id changes] (first entries)] + (recur (-> fdata + (cp/process-changes changes) + (ctst/update-object-indices page-id)) + (rest entries)) + fdata))))) + (-> state + (update-in [:workspace-libraries file-id :revn] max revn) + (update-in [:workspace-libraries file-id :data] + cp/process-changes changes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;