mirror of
https://github.com/mue/mue.git
synced 2026-06-05 23:45:53 +02:00
feat: improve image file handling and compression in CustomSettings component
This commit is contained in:
@@ -184,26 +184,31 @@ const CustomSettings = memo(() => {
|
|||||||
handleCustomBackground({ target: { result: reader.result } }, fileIndex);
|
handleCustomBackground({ target: { result: reader.result } }, fileIndex);
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
return;
|
} else {
|
||||||
|
// Handle image files
|
||||||
|
compressAccurately(file, {
|
||||||
|
size: 450,
|
||||||
|
accuracy: 0.9,
|
||||||
|
})
|
||||||
|
.then(async (res) => {
|
||||||
|
if (settingsSize + res.size > 4850000) {
|
||||||
|
return toast(variables.getMessage('toasts.no_storage'));
|
||||||
|
}
|
||||||
|
|
||||||
|
handleCustomBackground(
|
||||||
|
{
|
||||||
|
target: {
|
||||||
|
result: await filetoDataURL(res),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fileIndex,
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error compressing image:', error);
|
||||||
|
toast(variables.getMessage('toasts.error'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
compressAccurately(file, {
|
|
||||||
size: 450,
|
|
||||||
accuracy: 0.9,
|
|
||||||
}).then(async (res) => {
|
|
||||||
if (settingsSize + res.size > 4850000) {
|
|
||||||
return toast(variables.getMessage('toasts.no_storage'));
|
|
||||||
}
|
|
||||||
|
|
||||||
handleCustomBackground(
|
|
||||||
{
|
|
||||||
target: {
|
|
||||||
result: await filetoDataURL(res),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
fileIndex,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user