Handle thumbnail edge case

This commit is contained in:
Reece Browne 2025-08-26 11:56:57 +01:00
parent bb13df2b92
commit fe4720eaad

View File

@ -13,7 +13,7 @@ interface FileItem {
id: string; id: string;
name: string; name: string;
pageCount: number; pageCount: number;
thumbnail: string; thumbnail: string | null;
size: number; size: number;
splitBefore?: boolean; splitBefore?: boolean;
} }
@ -193,15 +193,16 @@ const FileThumbnail = ({
boxShadow: '2px 2px 0 rgba(0,0,0,0.1), 4px 4px 0 rgba(0,0,0,0.05)' boxShadow: '2px 2px 0 rgba(0,0,0,0.1), 4px 4px 0 rgba(0,0,0,0.05)'
}} }}
> >
<img {file.thumbnail && (
src={file.thumbnail} <img
alt={file.name} src={file.thumbnail}
draggable={false} alt={file.name}
onError={(e) => { draggable={false}
// Hide broken image if blob URL was revoked onError={(e) => {
const img = e.target as HTMLImageElement; // Hide broken image if blob URL was revoked
img.style.display = 'none'; const img = e.target as HTMLImageElement;
}} img.style.display = 'none';
}}
style={{ style={{
maxWidth: '100%', maxWidth: '100%',
maxHeight: '100%', maxHeight: '100%',
@ -209,6 +210,7 @@ const FileThumbnail = ({
borderRadius: 2, borderRadius: 2,
}} }}
/> />
)}
</div> </div>
{/* Page count badge - only show for PDFs */} {/* Page count badge - only show for PDFs */}