feat: generate and display thumbnails asynchronously

This commit is contained in:
2026-06-28 12:18:26 +03:00
parent 23933f47a0
commit affe9bcd14
16 changed files with 886 additions and 33 deletions

View File

@@ -40,9 +40,9 @@
class="group relative aspect-square cursor-pointer overflow-hidden rounded-lg border transition-all hover:border-sky-400/50
{selected ? 'border-sky-400/50 ring-1 ring-sky-400/50' : 'border-sky-200/20'}"
>
{#if isImage}
{#if isImage && file.thumbnailStoragePath}
<img
src={`/api/files/${file.id}/download`}
src={`/api/files/${file.id}/thumbnail`}
alt={file.name}
class="h-full w-full object-cover"
/>

View File

@@ -4,4 +4,5 @@ export type FileRecord = {
size: number;
fileType: string;
uploadedAt: string;
thumbnailStoragePath: string | null;
};

View File

@@ -82,6 +82,19 @@
window.location.href = '/auth';
}
$effect(() => {
const pending = fileRecords.some(
(f) => f.fileType.includes('image') && !f.thumbnailStoragePath
);
if (!pending) {
return;
}
const id = setInterval(refresh, 1000);
return () => clearInterval(id);
});
onMount(() => {
const saved = localStorage.getItem('viewMode');
if (saved === 'rows' || saved === 'tiles') viewMode = saved;