mirror of
https://github.com/penpot/penpot.git
synced 2025-05-24 13:36:11 +02:00
Merge pull request #1924 from penpot/fix-sync
🐛 Fix some component shapes not synced
This commit is contained in:
commit
426758d9b2
2 changed files with 42 additions and 8 deletions
|
@ -67,6 +67,38 @@
|
||||||
(db/insert! conn :file params)
|
(db/insert! conn :file params)
|
||||||
(:id file))))))
|
(:id file))))))
|
||||||
|
|
||||||
|
(defn repair-orphaned-components
|
||||||
|
"We have detected some cases of component instances that are not nested, but
|
||||||
|
however they have not the :component-root? attribute (so the system considers
|
||||||
|
them nested). This script fixes this adding them the attribute.
|
||||||
|
|
||||||
|
Use it with the update-file function above."
|
||||||
|
[data]
|
||||||
|
(let [update-page
|
||||||
|
(fn [page]
|
||||||
|
(prn "================= Page:" (:name page))
|
||||||
|
(letfn [(is-nested? [object]
|
||||||
|
(and (some? (:component-id object))
|
||||||
|
(nil? (:component-root? object))))
|
||||||
|
|
||||||
|
(is-instance? [object]
|
||||||
|
(some? (:shape-ref object)))
|
||||||
|
|
||||||
|
(get-parent [object]
|
||||||
|
(get (:objects page) (:parent-id object)))
|
||||||
|
|
||||||
|
(update-object [object]
|
||||||
|
(if (and (is-nested? object)
|
||||||
|
(not (is-instance? (get-parent object))))
|
||||||
|
(do
|
||||||
|
(prn "Orphan:" (:name object))
|
||||||
|
(assoc object :component-root? true))
|
||||||
|
object))]
|
||||||
|
|
||||||
|
(update page :objects d/update-vals update-object)))]
|
||||||
|
|
||||||
|
(update data :pages-index d/update-vals update-page)))
|
||||||
|
|
||||||
;; (defn check-image-shapes
|
;; (defn check-image-shapes
|
||||||
;; [{:keys [data] :as file} stats]
|
;; [{:keys [data] :as file} stats]
|
||||||
;; (println "=> analizing file:" (:name file) (:id file))
|
;; (println "=> analizing file:" (:name file) (:id file))
|
||||||
|
|
|
@ -549,16 +549,17 @@
|
||||||
(:shapes shape-main))
|
(:shapes shape-main))
|
||||||
|
|
||||||
only-inst (fn [changes child-inst]
|
only-inst (fn [changes child-inst]
|
||||||
(when-not (and omit-touched?
|
(if-not (and omit-touched?
|
||||||
(contains? (:touched shape-inst)
|
(contains? (:touched shape-inst)
|
||||||
:shapes-group))
|
:shapes-group))
|
||||||
(remove-shape changes
|
(remove-shape changes
|
||||||
child-inst
|
child-inst
|
||||||
container
|
container
|
||||||
omit-touched?)))
|
omit-touched?)
|
||||||
|
changes))
|
||||||
|
|
||||||
only-main (fn [changes child-main]
|
only-main (fn [changes child-main]
|
||||||
(when-not (and omit-touched?
|
(if-not (and omit-touched?
|
||||||
(contains? (:touched shape-inst)
|
(contains? (:touched shape-inst)
|
||||||
:shapes-group))
|
:shapes-group))
|
||||||
(add-shape-to-instance changes
|
(add-shape-to-instance changes
|
||||||
|
@ -570,7 +571,8 @@
|
||||||
root-inst
|
root-inst
|
||||||
root-main
|
root-main
|
||||||
omit-touched?
|
omit-touched?
|
||||||
set-remote-synced?)))
|
set-remote-synced?)
|
||||||
|
changes))
|
||||||
|
|
||||||
both (fn [changes child-inst child-main]
|
both (fn [changes child-inst child-main]
|
||||||
(generate-sync-shape-direct-recursive changes
|
(generate-sync-shape-direct-recursive changes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue