Merge remote-tracking branch 'origin/staging-2.19.x' into staging

This commit is contained in:
Andrey Antukh 2026-11-12 15:36:44 +01:00
commit ec1e2c9e1a
2 changed files with 23 additions and 8 deletions

View File

@ -1849,6 +1849,7 @@
(let [libraries (:shared-files state)
library (get libraries library-id)
variants-count (-> library :library-summary :variants count)
tokens-count (or (-> library :library-summary :tokens-count) 0)
loaded-libraries (->> (dsh/lookup-libraries state)
(remove (fn [[_ lib]]
@ -1869,14 +1870,25 @@
(rx/of (ntf/error (tr "errors.circular-library-reference")))
(rx/throw cause))))))
(rx/of (ptk/reify ::link-file-to-library-finished))
(when (pos? variants-count)
(when (or (pos? variants-count) (pos? tokens-count))
(->> (rp/cmd! :get-library-usage {:file-id library-id})
(rx/map (fn [library-usage]
(ev/event {::ev/name "link-file-to-library-variants"
:file-id file-id
:library-id library-id
:variants-count variants-count
:library-used-in (:used-in library-usage)}))))))))))
(rx/mapcat (fn [library-usage]
(let [used-in (:used-in library-usage)]
(rx/from
(cond-> []
(pos? variants-count)
(conj (ev/event {::ev/name "link-file-to-library-variants"
:file-id file-id
:library-id library-id
:variants-count variants-count
:library-used-in used-in}))
(pos? tokens-count)
(conj (ev/event {::ev/name "link-file-to-library-tokens"
:file-id file-id
:library-id library-id
:tokens-count tokens-count
:library-used-in used-in}))))))))))))))
(defn cleanup-unlinked-libraries
"Remove libraries from state that are no longer linked to the given file.

View File

@ -733,6 +733,8 @@
(all-attrs-appliable-for-token? attributes (:type token)))))))
shape-ids (d/nilv (keys shapes) [])
any-variant? (->> shapes vals (some ctk/is-variant?) boolean)
file-data (dsh/lookup-file-data state)
from-library (not (cfo/effective-tokens-source? file-data (:id file-data)))
resolved-value (get-in resolved-tokens [(:name token) :resolved-value])
tokenized-attributes (cfo/attributes-map attributes token)
@ -744,7 +746,8 @@
:type type
:applied-to attributes
:applied-to-variant any-variant?
:shape-count (count shape-ids)}
:shape-count (count shape-ids)
:from-library from-library}
(merge (meta it)))))
(dwu/start-undo-transaction undo-id)
(dwsh/update-shapes shape-ids (fn [shape]