mirror of
https://github.com/penpot/penpot.git
synced 2025-06-28 22:06:59 +02:00
🐛 Fix unexpected operation ordering.
This commit is contained in:
parent
75b64b71bf
commit
590b68aa29
3 changed files with 12 additions and 31 deletions
|
@ -181,7 +181,8 @@
|
||||||
"select s.id, s.changes
|
"select s.id, s.changes
|
||||||
from project_page_snapshots as s
|
from project_page_snapshots as s
|
||||||
where s.page_id = $1
|
where s.page_id = $1
|
||||||
and s.version > $2")
|
and s.version > $2
|
||||||
|
order by s.created_at asc")
|
||||||
|
|
||||||
(defn- retrieve-lagged-changes
|
(defn- retrieve-lagged-changes
|
||||||
[conn snapshot params]
|
[conn snapshot params]
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
;; --- Helpers
|
;; --- Helpers
|
||||||
|
|
||||||
(defn unpack-page
|
(defn unpack-page
|
||||||
[state {:keys [id data metadata] :as page}]
|
[state {:keys [id data] :as page}]
|
||||||
(-> state
|
(-> state
|
||||||
(update :pages assoc id (dissoc page :data))
|
(update :pages assoc id (dissoc page :data))
|
||||||
(update :pages-data assoc id data)))
|
(update :pages-data assoc id data)))
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
(declare handle-page-snapshot)
|
(declare handle-page-snapshot)
|
||||||
(declare shapes-changes-commited)
|
(declare shapes-changes-commited)
|
||||||
(declare commit-changes)
|
(declare commit-changes)
|
||||||
(declare commit-batched-changes)
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Websockets Events
|
;; Websockets Events
|
||||||
|
@ -245,7 +244,6 @@
|
||||||
(assoc state
|
(assoc state
|
||||||
:workspace-local workspace-default
|
:workspace-local workspace-default
|
||||||
:workspace-data data
|
:workspace-data data
|
||||||
:workspace-data-prev data
|
|
||||||
:workspace-page page)))
|
:workspace-page page)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
@ -274,8 +272,9 @@
|
||||||
(ptk/reify ::diff-and-commit-changes
|
(ptk/reify ::diff-and-commit-changes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [curr (get-in state [:workspace-data :shapes-by-id])
|
(let [pid (get-in state [:workspace-page :id])
|
||||||
prev (get-in state [:workspace-data-prev :shapes-by-id])
|
curr (get-in state [:workspace-data :shapes-by-id])
|
||||||
|
prev (get-in state [:pages-data pid :shapes-by-id])
|
||||||
|
|
||||||
diff (d/diff-maps prev curr)
|
diff (d/diff-maps prev curr)
|
||||||
changes (loop [scs (rest diff)
|
changes (loop [scs (rest diff)
|
||||||
|
@ -959,9 +958,7 @@
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [pid (get-in state [:workspace-page :id])
|
(let [pid (get-in state [:workspace-page :id])
|
||||||
data (get-in state [:pages-data pid])]
|
data (get-in state [:pages-data pid])]
|
||||||
(-> state
|
(update-in state [:pages-data pid] cp/process-changes changes)))
|
||||||
(update-in [:pages-data pid] cp/process-changes changes)
|
|
||||||
(assoc :workspace-data-prev (:workspace-data state)))))
|
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
|
@ -972,21 +969,6 @@
|
||||||
(->> (rp/mutation :update-project-page params)
|
(->> (rp/mutation :update-project-page params)
|
||||||
(rx/map shapes-changes-commited))))))
|
(rx/map shapes-changes-commited))))))
|
||||||
|
|
||||||
(def commit-batched-changes
|
|
||||||
(ptk/reify ::commit-batched-changes
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(let [pid (get-in state [:workspace-page :id])
|
|
||||||
data (get-in state [:pages-data pid])
|
|
||||||
changes (::batched-changes state)]
|
|
||||||
(update-in state [:pages-data pid] cp/process-changes changes)))
|
|
||||||
|
|
||||||
ptk/WatchEvent
|
|
||||||
(watch [_ state stream]
|
|
||||||
(let [changes (::batched-changes state)]
|
|
||||||
(rx/of #(dissoc % ::batched-changes)
|
|
||||||
(commit-changes changes))))))
|
|
||||||
|
|
||||||
(s/def ::shapes-changes-commited
|
(s/def ::shapes-changes-commited
|
||||||
(s/keys :req-un [::page-id ::version ::cp/changes]))
|
(s/keys :req-un [::page-id ::version ::cp/changes]))
|
||||||
|
|
||||||
|
@ -996,13 +978,11 @@
|
||||||
(ptk/reify ::shapes-changes-commited
|
(ptk/reify ::shapes-changes-commited
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [sid (:session-id state)
|
|
||||||
changes (remove #(= sid (:session-id %)) changes)]
|
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-in [:workspace-page :version] version)
|
(assoc-in [:workspace-page :version] version)
|
||||||
(assoc-in [:pages page-id :version] version)
|
(assoc-in [:pages page-id :version] version)
|
||||||
(update-in [:pages-data page-id] cp/process-changes changes)
|
(update-in [:pages-data page-id] cp/process-changes changes)
|
||||||
(update :workspace-data cp/process-changes changes))))))
|
(update :workspace-data cp/process-changes changes)))))
|
||||||
|
|
||||||
;; --- Start shape "edition mode"
|
;; --- Start shape "edition mode"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue