💄 Fix indentation style on generate-unapply-tokens

This commit is contained in:
Andrey Antukh 2025-07-30 11:45:19 +02:00
parent b262e6a46f
commit e1c5a32fcb

View File

@ -7,6 +7,7 @@
(ns app.common.logic.shapes (ns app.common.logic.shapes
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb] [app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh] [app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
@ -26,7 +27,7 @@
(defn- generate-unapply-tokens (defn- generate-unapply-tokens
"When updating attributes that have a token applied, we must unapply it, because the value "When updating attributes that have a token applied, we must unapply it, because the value
of the attribute now has been given directly, and does not come from the token. of the attribute now has been given directly, and does not come from the token.
When applying a typography asset style we also unapply any typographic tokens." When applying a typography asset style we also unapply any typographic tokens."
[changes objects changed-sub-attr] [changes objects changed-sub-attr]
(let [new-objects (pcb/get-objects changes) (let [new-objects (pcb/get-objects changes)
@ -44,26 +45,30 @@
attrs)] attrs)]
(apply set/union (map cto/shape-attr->token-attrs attrs)))) (apply set/union (map cto/shape-attr->token-attrs attrs))))
check-attr (fn [shape changes attr] check-attr
(let [tokens (get shape :applied-tokens {}) (fn [shape changes attr]
token-attrs (if (or (not= (:type shape) :text) (not= attr :content)) (let [shape-id (dm/get-prop shape :id)
(cto/shape-attr->token-attrs attr changed-sub-attr) tokens (get shape :applied-tokens {})
(text-changed-attrs shape))] token-attrs (if (and (cfh/text-shape? shape) (= attr :content))
(if (some #(contains? tokens %) token-attrs) (text-changed-attrs shape)
(pcb/update-shapes changes [(:id shape)] #(cto/unapply-token-id % token-attrs)) (cto/shape-attr->token-attrs attr changed-sub-attr))]
changes)))
check-shape (fn [changes mod-obj-change] (if (some #(contains? tokens %) token-attrs)
(let [shape (get objects (:id mod-obj-change)) (pcb/update-shapes changes [shape-id] #(cto/unapply-token-id % token-attrs))
xf (comp (filter #(= (:type %) :set)) changes)))
(map :attr))
attrs (into [] xf (:operations mod-obj-change))] check-shape
(reduce (partial check-attr shape) (fn [changes mod-obj-change]
changes (let [shape (get objects (:id mod-obj-change))
attrs)))] attrs (into []
(reduce check-shape (comp (filter #(= (:type %) :set))
changes (map :attr))
mod-obj-changes))) (:operations mod-obj-change))]
(reduce (partial check-attr shape)
changes
attrs)))]
(reduce check-shape changes mod-obj-changes)))
(defn generate-update-shapes (defn generate-update-shapes
[changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects?]}] [changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects?]}]