Merge branch 'hotfix/v1.0.1' of https://github.com/ONLYOFFICE/DocSpace into hotfix/v1.0.1

This commit is contained in:
Maria Sukhova 2023-05-02 15:14:43 +03:00
commit dc677e67d1

View File

@ -76,37 +76,45 @@ const Dropzone = ({ t, setUploadedFile, isDisabled }) => {
timer.current = setTimeout(() => {
setLoadingFile(true);
}, 50);
const imageBitMap = await createImageBitmap(file);
try {
const imageBitMap = await createImageBitmap(file);
const width = imageBitMap.width;
const height = imageBitMap.height;
const canvas = resizeImage.resize2Canvas(imageBitMap, width, height);
const width = imageBitMap.width;
const height = imageBitMap.height;
const canvas = resizeImage.resize2Canvas(imageBitMap, width, height);
resizeRecursiveAsync(
{ width, height },
canvas,
file.size > ONE_MEGABYTE ? COMPRESSION_RATIO : NO_COMPRESSION_RATIO
)
.then((file) => {
if (mount.current) {
setUploadedFile(file);
}
})
.catch((error) => {
if (
error instanceof Error &&
error.message === "recursion depth exceeded"
) {
toastr.error(t("Common:SizeImageLarge"));
}
console.error(error);
})
.finally(() => {
timer.current && clearTimeout(timer.current);
if (mount.current) {
setLoadingFile(false);
}
});
resizeRecursiveAsync(
{ width, height },
canvas,
file.size > ONE_MEGABYTE ? COMPRESSION_RATIO : NO_COMPRESSION_RATIO
)
.then((file) => {
if (mount.current) {
setUploadedFile(file);
}
})
.catch((error) => {
if (
error instanceof Error &&
error.message === "recursion depth exceeded"
) {
toastr.error(t("Common:SizeImageLarge"));
}
console.error(error);
})
.finally(() => {
timer.current && clearTimeout(timer.current);
if (mount.current) {
setLoadingFile(false);
}
});
} catch (error) {
toastr.error(error);
timer.current && clearTimeout(timer.current);
if (mount.current) {
setLoadingFile(false);
}
}
};
const { getRootProps, getInputProps } = useDropzone({