0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 15:51:37 -05:00

🐛 Some small fixes

* Remove an unneeded condition in sync.
* Correctly duplicate main instances.
* Slightly enhance sync logging.
This commit is contained in:
Andrés Moya 2022-08-17 14:28:37 +02:00 committed by Andrés Moya
parent bf63e9da95
commit 0c717c579b
3 changed files with 19 additions and 14 deletions

View file

@ -637,7 +637,9 @@
(when (and (some? file-id) (some? library-id)) ; Prevent race conditions while navigating out of the file
(log/info :msg "SYNC-FILE"
:file (dwlh/pretty-file file-id state)
:library (dwlh/pretty-file library-id state))
:library (dwlh/pretty-file library-id state)
:asset-type asset-type
:asset-id asset-id)
(let [file (wsh/get-file state file-id)
sync-components? (or (nil? asset-type) (= asset-type :components))
@ -713,10 +715,11 @@
(pcb/empty-changes it)
[(dwlh/generate-sync-file it file-id :components asset-id library-id state)
(dwlh/generate-sync-library it file-id :components asset-id library-id state)])]
(log/debug :msg "SYNC-FILE (2nd stage) finished" :js/rchanges (log-changes
(:redo-changes changes)
file))
(when (seq (:redo-changes changes))
(log/debug :msg "SYNC-FILE (2nd stage) finished" :js/rchanges (log-changes
(:redo-changes changes)
file))
(rx/of (dch/commit-changes (assoc changes :file-id file-id))))))))
(def ignore-sync
@ -788,6 +791,8 @@
#{}
changes)]
(when (d/not-empty? components-changed)
(log/info :msg "DETECTED COMPONENTS CHANGED"
:ids (map str components-changed))
(run! st/emit!
(map #(update-component-sync % (:id data))
components-changed)))))]

View file

@ -237,7 +237,7 @@
(log/debug :msg "Sync component in local library" :component-id (:id container)))
(let [linked-shapes (->> (vals (:objects container))
(filter #(uses-assets? asset-type asset-id % library-id (cph/page? container))))]
(filter #(uses-assets? asset-type asset-id % library-id)))]
(loop [shapes (seq linked-shapes)
changes (-> (pcb/empty-changes it)
(pcb/with-container container)
@ -254,23 +254,22 @@
(defmulti uses-assets?
"Checks if a shape uses some asset of the given type in the given library."
(fn [asset-type _ _ _ _] asset-type))
(fn [asset-type _ _ _] asset-type))
(defmethod uses-assets? :components
[_ component-id shape library-id page?]
(and (if (nil? component-id)
(ctk/uses-library-components? shape library-id)
(ctk/instance-of? shape library-id component-id))
(or (:component-root? shape) (not page?)))) ; avoid nested components inside pages
[_ component-id shape library-id]
(if (nil? component-id)
(ctk/uses-library-components? shape library-id)
(ctk/instance-of? shape library-id component-id)))
(defmethod uses-assets? :colors
[_ color-id shape library-id _]
[_ color-id shape library-id]
(if (nil? color-id)
(ctc/uses-library-colors? shape library-id)
(ctc/uses-library-color? shape library-id color-id)))
(defmethod uses-assets? :typographies
[_ typography-id shape library-id _]
[_ typography-id shape library-id]
(if (nil? typography-id)
(cty/uses-library-typographies? shape library-id)
(cty/uses-library-typography? shape library-id typography-id)))

View file

@ -360,7 +360,8 @@
:name name
:parent-id parent-id
:frame-id frame-id)
(dissoc :shapes)
(dissoc :shapes
:main-instance?)
(gsh/move delta)
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))