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 (
|
||||
Object.prototype.hasOwnProperty.call(body.textAssignments, layer.id)
|
||||
) {
|
||||
if (Object.hasOwn(body.textAssignments, layer.id)) {
|
||||
textAssignments[layer.id] = String(
|
||||
body.textAssignments[layer.id] ?? ""
|
||||
).trim();
|
||||
@ -115,7 +113,7 @@ export async function executeAgentPsdTemplateRenderRequest(
|
||||
layer.isRequired &&
|
||||
(isAgentPsdImageLayerSlot(layer)
|
||||
? !imageAssignments[layer.id]
|
||||
: !Object.prototype.hasOwnProperty.call(textAssignments, layer.id) &&
|
||||
: !Object.hasOwn(textAssignments, layer.id) &&
|
||||
!String(layer.defaultText || "").trim())
|
||||
);
|
||||
if (missingRequiredLayer) {
|
||||
|
||||
@ -528,10 +528,7 @@ export async function renderAgentPsdTemplate(params: {
|
||||
}
|
||||
|
||||
if (isAgentPsdTextLayerSlot(layer)) {
|
||||
const hasTextAssignment = Object.prototype.hasOwnProperty.call(
|
||||
textAssignments,
|
||||
layer.id
|
||||
);
|
||||
const hasTextAssignment = Object.hasOwn(textAssignments, layer.id);
|
||||
const defaultText = String(layer.defaultText || "").trim();
|
||||
const text = String(
|
||||
hasTextAssignment ? textAssignments[layer.id] ?? "" : defaultText
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user