refactor: simplify psd text assignment checks
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-04-15 21:17:20 +08:00
parent 71997086e1
commit 71c537fdb7
2 changed files with 3 additions and 8 deletions

View File

@ -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) {

View File

@ -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