mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
✨ Prevent adding object map to not loaded pointer-map containers
This commit is contained in:
parent
3212ed9bd1
commit
ba55d657a4
3 changed files with 24 additions and 8 deletions
|
@ -22,12 +22,21 @@
|
||||||
|
|
||||||
(defn enable-objects-map
|
(defn enable-objects-map
|
||||||
[file]
|
[file]
|
||||||
(let [update-fn #(d/update-when % :objects omap/wrap)]
|
(let [update-container
|
||||||
|
(fn [container]
|
||||||
|
(if (and (pmap/pointer-map? container)
|
||||||
|
(not (pmap/loaded? container)))
|
||||||
|
container
|
||||||
|
(d/update-when container :objects omap/wrap)))
|
||||||
|
|
||||||
|
update-data
|
||||||
|
(fn [fdata]
|
||||||
|
(-> fdata
|
||||||
|
(update :pages-index d/update-vals update-container)
|
||||||
|
(d/update-when :components d/update-vals update-container)))]
|
||||||
|
|
||||||
(-> file
|
(-> file
|
||||||
(update :data (fn [fdata]
|
(update :data update-data)
|
||||||
(-> fdata
|
|
||||||
(update :pages-index update-vals update-fn)
|
|
||||||
(d/update-when :components update-vals update-fn))))
|
|
||||||
(update :features conj "fdata/objects-map"))))
|
(update :features conj "fdata/objects-map"))))
|
||||||
|
|
||||||
(defn process-objects
|
(defn process-objects
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
(get-id [_])
|
(get-id [_])
|
||||||
(load! [_])
|
(load! [_])
|
||||||
(modified? [_])
|
(modified? [_])
|
||||||
|
(loaded? [_])
|
||||||
(clone [_]))
|
(clone [_]))
|
||||||
|
|
||||||
(deftype PointerMap [id mdata
|
(deftype PointerMap [id mdata
|
||||||
|
@ -90,6 +91,7 @@
|
||||||
(or odata {}))
|
(or odata {}))
|
||||||
|
|
||||||
(modified? [_] modified?)
|
(modified? [_] modified?)
|
||||||
|
(loaded? [_] loaded?)
|
||||||
(get-id [_] id)
|
(get-id [_] id)
|
||||||
|
|
||||||
(clone [this]
|
(clone [this]
|
||||||
|
@ -210,8 +212,6 @@
|
||||||
(defn create
|
(defn create
|
||||||
([]
|
([]
|
||||||
(let [id (uuid/next)
|
(let [id (uuid/next)
|
||||||
|
|
||||||
|
|
||||||
mdata (assoc *metadata* :created-at (dt/now))
|
mdata (assoc *metadata* :created-at (dt/now))
|
||||||
pmap (PointerMap. id mdata {} true true)]
|
pmap (PointerMap. id mdata {} true true)]
|
||||||
(some-> *tracked* (swap! assoc id pmap))
|
(some-> *tracked* (swap! assoc id pmap))
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
(ns app.common.data
|
(ns app.common.data
|
||||||
"A collection if helpers for working with data structures and other
|
"A collection if helpers for working with data structures and other
|
||||||
data resources."
|
data resources."
|
||||||
(:refer-clojure :exclude [read-string hash-map merge name
|
(:refer-clojure :exclude [read-string hash-map merge name update-vals
|
||||||
parse-double group-by iteration concat mapcat
|
parse-double group-by iteration concat mapcat
|
||||||
parse-uuid max min])
|
parse-uuid max min])
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
|
@ -403,6 +403,13 @@
|
||||||
[coll]
|
[coll]
|
||||||
(partial get coll))
|
(partial get coll))
|
||||||
|
|
||||||
|
(defn update-vals
|
||||||
|
[m f]
|
||||||
|
(reduce-kv (fn [acc k v]
|
||||||
|
(assoc acc k (f v)))
|
||||||
|
m
|
||||||
|
m))
|
||||||
|
|
||||||
(defn update-in-when
|
(defn update-in-when
|
||||||
[m key-seq f & args]
|
[m key-seq f & args]
|
||||||
(let [found (get-in m key-seq sentinel)]
|
(let [found (get-in m key-seq sentinel)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue