mirror of
https://github.com/penpot/penpot.git
synced 2025-03-14 16:51:18 -05:00
🐛 Some small fixes
* Remove an unneeded condition in sync. * Correctly duplicate main instances. * Slightly enhance sync logging.
This commit is contained in:
parent
bf63e9da95
commit
0c717c579b
3 changed files with 19 additions and 14 deletions
|
@ -637,7 +637,9 @@
|
||||||
(when (and (some? file-id) (some? library-id)) ; Prevent race conditions while navigating out of the file
|
(when (and (some? file-id) (some? library-id)) ; Prevent race conditions while navigating out of the file
|
||||||
(log/info :msg "SYNC-FILE"
|
(log/info :msg "SYNC-FILE"
|
||||||
:file (dwlh/pretty-file file-id state)
|
: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)
|
(let [file (wsh/get-file state file-id)
|
||||||
|
|
||||||
sync-components? (or (nil? asset-type) (= asset-type :components))
|
sync-components? (or (nil? asset-type) (= asset-type :components))
|
||||||
|
@ -713,10 +715,11 @@
|
||||||
(pcb/empty-changes it)
|
(pcb/empty-changes it)
|
||||||
[(dwlh/generate-sync-file it file-id :components asset-id library-id state)
|
[(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)])]
|
(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))
|
(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))))))))
|
(rx/of (dch/commit-changes (assoc changes :file-id file-id))))))))
|
||||||
|
|
||||||
(def ignore-sync
|
(def ignore-sync
|
||||||
|
@ -788,6 +791,8 @@
|
||||||
#{}
|
#{}
|
||||||
changes)]
|
changes)]
|
||||||
(when (d/not-empty? components-changed)
|
(when (d/not-empty? components-changed)
|
||||||
|
(log/info :msg "DETECTED COMPONENTS CHANGED"
|
||||||
|
:ids (map str components-changed))
|
||||||
(run! st/emit!
|
(run! st/emit!
|
||||||
(map #(update-component-sync % (:id data))
|
(map #(update-component-sync % (:id data))
|
||||||
components-changed)))))]
|
components-changed)))))]
|
||||||
|
|
|
@ -237,7 +237,7 @@
|
||||||
(log/debug :msg "Sync component in local library" :component-id (:id container)))
|
(log/debug :msg "Sync component in local library" :component-id (:id container)))
|
||||||
|
|
||||||
(let [linked-shapes (->> (vals (:objects 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)
|
(loop [shapes (seq linked-shapes)
|
||||||
changes (-> (pcb/empty-changes it)
|
changes (-> (pcb/empty-changes it)
|
||||||
(pcb/with-container container)
|
(pcb/with-container container)
|
||||||
|
@ -254,23 +254,22 @@
|
||||||
|
|
||||||
(defmulti uses-assets?
|
(defmulti uses-assets?
|
||||||
"Checks if a shape uses some asset of the given type in the given library."
|
"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
|
(defmethod uses-assets? :components
|
||||||
[_ component-id shape library-id page?]
|
[_ component-id shape library-id]
|
||||||
(and (if (nil? component-id)
|
(if (nil? component-id)
|
||||||
(ctk/uses-library-components? shape library-id)
|
(ctk/uses-library-components? shape library-id)
|
||||||
(ctk/instance-of? shape library-id component-id))
|
(ctk/instance-of? shape library-id component-id)))
|
||||||
(or (:component-root? shape) (not page?)))) ; avoid nested components inside pages
|
|
||||||
|
|
||||||
(defmethod uses-assets? :colors
|
(defmethod uses-assets? :colors
|
||||||
[_ color-id shape library-id _]
|
[_ color-id shape library-id]
|
||||||
(if (nil? color-id)
|
(if (nil? color-id)
|
||||||
(ctc/uses-library-colors? shape library-id)
|
(ctc/uses-library-colors? shape library-id)
|
||||||
(ctc/uses-library-color? shape library-id color-id)))
|
(ctc/uses-library-color? shape library-id color-id)))
|
||||||
|
|
||||||
(defmethod uses-assets? :typographies
|
(defmethod uses-assets? :typographies
|
||||||
[_ typography-id shape library-id _]
|
[_ typography-id shape library-id]
|
||||||
(if (nil? typography-id)
|
(if (nil? typography-id)
|
||||||
(cty/uses-library-typographies? shape library-id)
|
(cty/uses-library-typographies? shape library-id)
|
||||||
(cty/uses-library-typography? shape library-id typography-id)))
|
(cty/uses-library-typography? shape library-id typography-id)))
|
||||||
|
|
|
@ -360,7 +360,8 @@
|
||||||
:name name
|
:name name
|
||||||
:parent-id parent-id
|
:parent-id parent-id
|
||||||
:frame-id frame-id)
|
:frame-id frame-id)
|
||||||
(dissoc :shapes)
|
(dissoc :shapes
|
||||||
|
:main-instance?)
|
||||||
(gsh/move delta)
|
(gsh/move delta)
|
||||||
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))
|
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue