This commit is contained in:
Yinyin Liu 2026-04-28 15:45:10 +02:00
parent b93c051d5f
commit ed00b742a1
1 changed files with 8 additions and 2 deletions

View File

@ -136,13 +136,19 @@ function DocumentList({
}); });
}, [documents]); }, [documents]);
// Clean up blob URLs on unmount // Revoke superseded blob URLs as state changes, and on unmount.
// Empty deps would capture the initial {} and never revoke anything.
useEffect(() => { useEffect(() => {
return () => { return () => {
Object.values(previews).forEach((url) => window.URL.revokeObjectURL(url)); Object.values(previews).forEach((url) => window.URL.revokeObjectURL(url));
};
}, [previews]);
useEffect(() => {
return () => {
Object.values(videoUrls).forEach((url) => window.URL.revokeObjectURL(url)); Object.values(videoUrls).forEach((url) => window.URL.revokeObjectURL(url));
}; };
}, []); }, [videoUrls]);
const handleDownload = (doc: DocumentItem) => { const handleDownload = (doc: DocumentItem) => {
const cached = previews[doc.id] || videoUrls[doc.id]; const cached = previews[doc.id] || videoUrls[doc.id];