feat: improve image file handling and compression in CustomSettings component

This commit is contained in:
alexsparkes
2026-01-24 22:37:34 +00:00
parent cb30790fae
commit 9688f0ba96

View File

@@ -184,13 +184,13 @@ 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, { compressAccurately(file, {
size: 450, size: 450,
accuracy: 0.9, accuracy: 0.9,
}).then(async (res) => { })
.then(async (res) => {
if (settingsSize + res.size > 4850000) { if (settingsSize + res.size > 4850000) {
return toast(variables.getMessage('toasts.no_storage')); return toast(variables.getMessage('toasts.no_storage'));
} }
@@ -203,7 +203,12 @@ const CustomSettings = memo(() => {
}, },
fileIndex, fileIndex,
); );
})
.catch((error) => {
console.error('Error compressing image:', error);
toast(variables.getMessage('toasts.error'));
}); });
}
}); });
}; };