Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -102,6 +102,10 @@ export function CloudLoader({ compact = false, variant = 'outline', className }:
|
|||||||
|
|
||||||
const handleLoad = useCallback(async (rawUrl: string) => {
|
const handleLoad = useCallback(async (rawUrl: string) => {
|
||||||
if (!rawUrl) return;
|
if (!rawUrl) return;
|
||||||
|
if (modelsCount >= maxModels) {
|
||||||
|
toast.error(`Limite de ${maxModels} peças simultâneas atingido. Remova uma antes de adicionar outra.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const fileName = rawUrl.split('/').pop()?.split('?')[0] || 'modelo-cloud';
|
const fileName = rawUrl.split('/').pop()?.split('?')[0] || 'modelo-cloud';
|
||||||
@@ -125,8 +129,8 @@ export function CloudLoader({ compact = false, variant = 'outline', className }:
|
|||||||
blob = r.blob; outName = r.fileName; outSize = r.fileSize;
|
blob = r.blob; outName = r.fileName; outSize = r.fileSize;
|
||||||
}
|
}
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
setModel({ fileName: outName, fileSize: outSize, url: blobUrl });
|
addModel({ fileName: outName, fileSize: outSize, url: blobUrl });
|
||||||
toast.success(`"${outName}" carregado da nuvem`);
|
toast.success(`"${outName}" adicionado à cena`);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@@ -134,7 +138,7 @@ export function CloudLoader({ compact = false, variant = 'outline', className }:
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [setModel]);
|
}, [addModel, modelsCount, maxModels]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
|
|||||||
Reference in New Issue
Block a user