mirror of
https://github.com/penpot/penpot.git
synced 2025-03-10 14:51:37 -05: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
|
||||
[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
|
||||
(update :data (fn [fdata]
|
||||
(-> fdata
|
||||
(update :pages-index update-vals update-fn)
|
||||
(d/update-when :components update-vals update-fn))))
|
||||
(update :data update-data)
|
||||
(update :features conj "fdata/objects-map"))))
|
||||
|
||||
(defn process-objects
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
(get-id [_])
|
||||
(load! [_])
|
||||
(modified? [_])
|
||||
(loaded? [_])
|
||||
(clone [_]))
|
||||
|
||||
(deftype PointerMap [id mdata
|
||||
|
@ -90,6 +91,7 @@
|
|||
(or odata {}))
|
||||
|
||||
(modified? [_] modified?)
|
||||
(loaded? [_] loaded?)
|
||||
(get-id [_] id)
|
||||
|
||||
(clone [this]
|
||||
|
@ -210,8 +212,6 @@
|
|||
(defn create
|
||||
([]
|
||||
(let [id (uuid/next)
|
||||
|
||||
|
||||
mdata (assoc *metadata* :created-at (dt/now))
|
||||
pmap (PointerMap. id mdata {} true true)]
|
||||
(some-> *tracked* (swap! assoc id pmap))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
(ns app.common.data
|
||||
"A collection if helpers for working with data structures and other
|
||||
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-uuid max min])
|
||||
#?(:cljs
|
||||
|
@ -403,6 +403,13 @@
|
|||
[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
|
||||
[m key-seq f & args]
|
||||
(let [found (get-in m key-seq sentinel)]
|
||||
|
|
Loading…
Add table
Reference in a new issue