mirror of
https://github.com/penpot/penpot.git
synced 2025-05-17 04:46:11 +02:00
🐛 Remove interactions when the destination artboard is deleted
This commit is contained in:
parent
e241273a1e
commit
af23d62568
4 changed files with 47 additions and 4 deletions
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
### :sparkles: New features
|
### :sparkles: New features
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
|
- Remove interactions when the destination artboard is deleted [Taiga #1656](https://tree.taiga.io/project/penpot/issue/1656)
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
### :boom: Breaking changes
|
### :boom: Breaking changes
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.uuid :as uuid]))
|
[app.common.uuid :as uuid]))
|
||||||
|
|
||||||
(def file-version 6)
|
(def file-version 7)
|
||||||
(def default-color "#b1b2b5") ;; $color-gray-20
|
(def default-color "#b1b2b5") ;; $color-gray-20
|
||||||
(def root uuid/zero)
|
(def root uuid/zero)
|
||||||
|
|
||||||
|
|
|
@ -163,3 +163,19 @@
|
||||||
(-> data
|
(-> data
|
||||||
(update :components #(d/mapm update-container %))
|
(update :components #(d/mapm update-container %))
|
||||||
(update :pages-index #(d/mapm update-container %)))))
|
(update :pages-index #(d/mapm update-container %)))))
|
||||||
|
|
||||||
|
|
||||||
|
;; Remove interactions pointing to deleted frames
|
||||||
|
(defmethod migrate 7
|
||||||
|
[data]
|
||||||
|
(letfn [(update-object [page _ object]
|
||||||
|
(d/update-when object :interactions
|
||||||
|
(fn [interactions]
|
||||||
|
(filterv #(get-in page [:objects (:destination %)])
|
||||||
|
interactions))))
|
||||||
|
|
||||||
|
(update-page [_ page]
|
||||||
|
(update page :objects #(d/mapm (partial update-object page) %)))]
|
||||||
|
|
||||||
|
(update data :pages-index #(d/mapm update-page %))))
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,6 @@
|
||||||
:shapes [shape-id]})))]
|
:shapes [shape-id]})))]
|
||||||
(rx/of (dch/commit-changes rchanges uchanges {:commit-local? true}))))))
|
(rx/of (dch/commit-changes rchanges uchanges {:commit-local? true}))))))
|
||||||
|
|
||||||
|
|
||||||
(defn delete-shapes
|
(defn delete-shapes
|
||||||
[ids]
|
[ids]
|
||||||
(us/assert (s/coll-of ::us/uuid) ids)
|
(us/assert (s/coll-of ::us/uuid) ids)
|
||||||
|
@ -366,6 +365,12 @@
|
||||||
#{}
|
#{}
|
||||||
ids)
|
ids)
|
||||||
|
|
||||||
|
interacting-shapes
|
||||||
|
(filter (fn [shape]
|
||||||
|
(let [interactions (:interactions shape)]
|
||||||
|
(some ids (map :destination interactions))))
|
||||||
|
(vals objects))
|
||||||
|
|
||||||
rchanges
|
rchanges
|
||||||
(d/concat
|
(d/concat
|
||||||
(reduce (fn [res id]
|
(reduce (fn [res id]
|
||||||
|
@ -391,7 +396,18 @@
|
||||||
:operations [{:type :set
|
:operations [{:type :set
|
||||||
:attr :masked-group?
|
:attr :masked-group?
|
||||||
:val false}])
|
:val false}])
|
||||||
groups-to-unmask))
|
groups-to-unmask)
|
||||||
|
(map #(array-map
|
||||||
|
:type :mod-obj
|
||||||
|
:page-id page-id
|
||||||
|
:id (:id %)
|
||||||
|
:operations [{:type :set
|
||||||
|
:attr :interactions
|
||||||
|
:val (vec (remove (fn [interaction]
|
||||||
|
(contains? ids (:destination interaction)))
|
||||||
|
(:interactions %)))}])
|
||||||
|
interacting-shapes))
|
||||||
|
|
||||||
|
|
||||||
uchanges
|
uchanges
|
||||||
(d/concat
|
(d/concat
|
||||||
|
@ -430,7 +446,15 @@
|
||||||
:operations [{:type :set
|
:operations [{:type :set
|
||||||
:attr :masked-group?
|
:attr :masked-group?
|
||||||
:val true}])
|
:val true}])
|
||||||
groups-to-unmask))]
|
groups-to-unmask)
|
||||||
|
(map #(array-map
|
||||||
|
:type :mod-obj
|
||||||
|
:page-id page-id
|
||||||
|
:id (:id %)
|
||||||
|
:operations [{:type :set
|
||||||
|
:attr :interactions
|
||||||
|
:val (:interactions %)}])
|
||||||
|
interacting-shapes))]
|
||||||
|
|
||||||
;; (println "================ rchanges")
|
;; (println "================ rchanges")
|
||||||
;; (cljs.pprint/pprint rchanges)
|
;; (cljs.pprint/pprint rchanges)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue