mirror of
https://github.com/penpot/penpot.git
synced 2025-07-22 01:47:12 +02:00
🐛 Fix possible race condition on component rename and deletion
This commit is contained in:
parent
ce61b783fb
commit
82796822d1
2 changed files with 24 additions and 20 deletions
|
@ -5,6 +5,7 @@
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
- Fix issue on handling empty content on boolean shapes
|
- Fix issue on handling empty content on boolean shapes
|
||||||
|
- Fix race condition issue on component renaming
|
||||||
- Handle EOF errors on writting streamed response
|
- Handle EOF errors on writting streamed response
|
||||||
- Handle EOF errors on websocket send/ping methods
|
- Handle EOF errors on websocket send/ping methods
|
||||||
- Disable parallel upload of file media on import (causes too much
|
- Disable parallel upload of file media on import (causes too much
|
||||||
|
|
|
@ -314,29 +314,32 @@
|
||||||
(ptk/reify ::rename-component
|
(ptk/reify ::rename-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [[path name] (cp/parse-path-name new-name)
|
;; NOTE: we need to ensure the component exists, because there
|
||||||
component (get-in state [:workspace-data :components id])
|
;; are small posibilities of race conditions with component
|
||||||
objects (get component :objects)
|
;; deletion.
|
||||||
; Give the same name to the root shape
|
(when-let [component (get-in state [:workspace-data :components id])]
|
||||||
new-objects (assoc-in objects
|
(let [[path name] (cp/parse-path-name new-name)
|
||||||
[(:id component) :name]
|
objects (get component :objects)
|
||||||
name)
|
;; Give the same name to the root shape
|
||||||
|
new-objects (assoc-in objects
|
||||||
|
[(:id component) :name]
|
||||||
|
name)
|
||||||
|
|
||||||
rchanges [{:type :mod-component
|
rchanges [{:type :mod-component
|
||||||
:id id
|
:id id
|
||||||
:name name
|
:name name
|
||||||
:path path
|
:path path
|
||||||
:objects new-objects}]
|
:objects new-objects}]
|
||||||
|
|
||||||
uchanges [{:type :mod-component
|
uchanges [{:type :mod-component
|
||||||
:id id
|
:id id
|
||||||
:name (:name component)
|
:name (:name component)
|
||||||
:path (:path component)
|
:path (:path component)
|
||||||
:objects objects}]]
|
:objects objects}]]
|
||||||
|
|
||||||
(rx/of (dch/commit-changes {:redo-changes rchanges
|
(rx/of (dch/commit-changes {:redo-changes rchanges
|
||||||
:undo-changes uchanges
|
:undo-changes uchanges
|
||||||
:origin it}))))))
|
:origin it})))))))
|
||||||
|
|
||||||
(defn duplicate-component
|
(defn duplicate-component
|
||||||
"Create a new component copied from the one with the given id."
|
"Create a new component copied from the one with the given id."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue