fix: stop psd dialog update loop
This commit is contained in:
parent
8853bfae77
commit
494a3c6d48
@ -510,7 +510,12 @@ export function AgentPsdTemplateEditorDialog({
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedTemplate) {
|
||||
setImageSizes({});
|
||||
setImageSizes((current) => {
|
||||
if (Object.keys(current).length === 0) {
|
||||
return current;
|
||||
}
|
||||
return {};
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeof window === "undefined" || typeof window.Image !== "function") {
|
||||
@ -532,13 +537,24 @@ export function AgentPsdTemplateEditorDialog({
|
||||
const image = new window.Image();
|
||||
image.onload = () => {
|
||||
if (cancelled) return;
|
||||
setImageSizes((current) => ({
|
||||
...current,
|
||||
[layer.id]: {
|
||||
width: Math.max(1, image.naturalWidth || layer.width),
|
||||
height: Math.max(1, image.naturalHeight || layer.height),
|
||||
},
|
||||
}));
|
||||
const nextWidth = Math.max(1, image.naturalWidth || layer.width);
|
||||
const nextHeight = Math.max(1, image.naturalHeight || layer.height);
|
||||
setImageSizes((current) => {
|
||||
if (
|
||||
current[layer.id]?.width === nextWidth &&
|
||||
current[layer.id]?.height === nextHeight
|
||||
) {
|
||||
return current;
|
||||
}
|
||||
|
||||
return {
|
||||
...current,
|
||||
[layer.id]: {
|
||||
width: nextWidth,
|
||||
height: nextHeight,
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
image.src = assignedUrl;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user