mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 14:41:37 +02:00
🐛 Fix duplicate frame issues
This commit is contained in:
parent
d68be0869b
commit
7e21d827c9
1 changed files with 16 additions and 7 deletions
|
@ -23,6 +23,7 @@
|
||||||
[app.main.data.workspace.collapse :as dwc]
|
[app.main.data.workspace.collapse :as dwc]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.thumbnails :as dwt]
|
[app.main.data.workspace.thumbnails :as dwt]
|
||||||
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.data.workspace.zoom :as dwz]
|
[app.main.data.workspace.zoom :as dwz]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
|
@ -502,8 +503,11 @@
|
||||||
[obj state objects]
|
[obj state objects]
|
||||||
(let [{:keys [id-original id-duplicated]}
|
(let [{:keys [id-original id-duplicated]}
|
||||||
(get-in state [:workspace-local :duplicated])]
|
(get-in state [:workspace-local :duplicated])]
|
||||||
(if (and (not= id-original (:id obj))
|
(if (or (and (not= id-original (:id obj))
|
||||||
(not= id-duplicated (:id obj)))
|
(not= id-duplicated (:id obj)))
|
||||||
|
;; As we can remove duplicated elements may be we can still caching a deleted id
|
||||||
|
(not (contains? objects id-original))
|
||||||
|
(not (contains? objects id-duplicated)))
|
||||||
|
|
||||||
;; The default is leave normal shapes in place, but put
|
;; The default is leave normal shapes in place, but put
|
||||||
;; new frames to the right of the original.
|
;; new frames to the right of the original.
|
||||||
|
@ -556,16 +560,21 @@
|
||||||
|
|
||||||
frames (into #{}
|
frames (into #{}
|
||||||
(map #(get-in objects [% :frame-id]))
|
(map #(get-in objects [% :frame-id]))
|
||||||
selected)]
|
selected)
|
||||||
|
undo-id (uuid/next)]
|
||||||
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(->> (rx/from dup-frames)
|
(->> (rx/from dup-frames)
|
||||||
(rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id))))
|
(rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id))))
|
||||||
|
|
||||||
;; Warning: This order is important for the focus mode.
|
;; Warning: This order is important for the focus mode.
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of
|
||||||
(select-shapes new-selected)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(ptk/data-event :layout/update frames)
|
(dch/commit-changes changes)
|
||||||
(memorize-duplicated id-original id-duplicated))))))))))
|
(select-shapes new-selected)
|
||||||
|
(ptk/data-event :layout/update frames)
|
||||||
|
(memorize-duplicated id-original id-duplicated)
|
||||||
|
(dwu/commit-undo-transaction undo-id))))))))))
|
||||||
|
|
||||||
(defn change-hover-state
|
(defn change-hover-state
|
||||||
[id value]
|
[id value]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue