feat: Improve file preview with Blob URLs

Utilize `URL.createObjectURL` for richer file previews, especially for PDFs. This approach provides better compatibility and performance compared to Base64 previews.

Introduces memory leak prevention by revoking Blob URLs when the component unmounts or the app resets.
This commit is contained in:
Kenearos 2026-02-06 14:29:07 +01:00
parent 778caa8a45
commit d6cab4aeb5
3 changed files with 70 additions and 31 deletions

10
App.tsx
View file

@ -44,6 +44,14 @@ const App: React.FC = () => {
};
const reset = () => {
// Cleanup blob URLs to prevent memory leaks
if (formFile?.previewUrl && formFile.previewUrl.startsWith('blob:')) {
URL.revokeObjectURL(formFile.previewUrl);
}
if (sourceFile?.previewUrl && sourceFile.previewUrl.startsWith('blob:')) {
URL.revokeObjectURL(sourceFile.previewUrl);
}
setStatus(AppStatus.IDLE);
setFormFile(null);
setSourceFile(null);
@ -223,4 +231,4 @@ const App: React.FC = () => {
);
};
export default App;
export default App;