refactor: simplify psd text assignment checks
This commit is contained in:
parent
71997086e1
commit
71c537fdb7
@ -95,9 +95,7 @@ export async function executeAgentPsdTemplateRenderRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAgentPsdTextLayerSlot(layer)) {
|
if (isAgentPsdTextLayerSlot(layer)) {
|
||||||
if (
|
if (Object.hasOwn(body.textAssignments, layer.id)) {
|
||||||
Object.prototype.hasOwnProperty.call(body.textAssignments, layer.id)
|
|
||||||
) {
|
|
||||||
textAssignments[layer.id] = String(
|
textAssignments[layer.id] = String(
|
||||||
body.textAssignments[layer.id] ?? ""
|
body.textAssignments[layer.id] ?? ""
|
||||||
).trim();
|
).trim();
|
||||||
@ -115,7 +113,7 @@ export async function executeAgentPsdTemplateRenderRequest(
|
|||||||
layer.isRequired &&
|
layer.isRequired &&
|
||||||
(isAgentPsdImageLayerSlot(layer)
|
(isAgentPsdImageLayerSlot(layer)
|
||||||
? !imageAssignments[layer.id]
|
? !imageAssignments[layer.id]
|
||||||
: !Object.prototype.hasOwnProperty.call(textAssignments, layer.id) &&
|
: !Object.hasOwn(textAssignments, layer.id) &&
|
||||||
!String(layer.defaultText || "").trim())
|
!String(layer.defaultText || "").trim())
|
||||||
);
|
);
|
||||||
if (missingRequiredLayer) {
|
if (missingRequiredLayer) {
|
||||||
|
|||||||
@ -528,10 +528,7 @@ export async function renderAgentPsdTemplate(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAgentPsdTextLayerSlot(layer)) {
|
if (isAgentPsdTextLayerSlot(layer)) {
|
||||||
const hasTextAssignment = Object.prototype.hasOwnProperty.call(
|
const hasTextAssignment = Object.hasOwn(textAssignments, layer.id);
|
||||||
textAssignments,
|
|
||||||
layer.id
|
|
||||||
);
|
|
||||||
const defaultText = String(layer.defaultText || "").trim();
|
const defaultText = String(layer.defaultText || "").trim();
|
||||||
const text = String(
|
const text = String(
|
||||||
hasTextAssignment ? textAssignments[layer.id] ?? "" : defaultText
|
hasTextAssignment ? textAssignments[layer.id] ?? "" : defaultText
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user