|
19 | 19 |
|
20 | 20 | let previewDataUrls = $state<Record<string, string>>({}); |
21 | 21 | let previewPending = new Set<string>(); |
| 22 | + let previewTick = $state(0); |
22 | 23 |
|
23 | 24 | async function loadPreview(path: string) { |
24 | 25 | if (previewDataUrls[path] || previewPending.has(path)) return; |
|
27 | 28 | const app = await getApp(); |
28 | 29 | const previewPath = await app.GetPreview(path); |
29 | 30 | const dataUrl = await app.ReadImageAsDataURL(previewPath); |
30 | | - previewDataUrls = {...previewDataUrls, [path]: dataUrl}; |
| 31 | + previewDataUrls[path] = dataUrl; |
| 32 | + previewTick++; |
31 | 33 | } catch {} |
32 | 34 | previewPending.delete(path); |
33 | 35 | } |
34 | 36 |
|
| 37 | + function hasPreview(path: string): string | undefined { |
| 38 | + void previewTick; |
| 39 | + return previewDataUrls[path]; |
| 40 | + } |
| 41 | +
|
35 | 42 | let _appModule: Awaited< |
36 | 43 | typeof import('../../../../wailsjs/go/main/App') |
37 | 44 | > | null = null; |
|
122 | 129 |
|
123 | 130 | if (uncached.length === 0) return; |
124 | 131 |
|
125 | | - const CONCURRENCY = 4; |
| 132 | + const CONCURRENCY = 8; |
126 | 133 | cacheTotal = uncached.length; |
127 | 134 | cacheProgress = 0; |
128 | 135 | isCaching = true; |
|
502 | 509 | : CARD_MAX_HEIGHT}px; |
503 | 510 | transform: skewX(-{SKEW}deg); |
504 | 511 | opacity: {slideOpacity(i)}; |
| 512 | + contain: layout style paint; |
505 | 513 | transition: width 0.2s ease, height 0.2s ease, opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease; |
506 | 514 | border-color: {i === currentIndex |
507 | 515 | ? accentColor |
|
515 | 523 | aria-selected={i === currentIndex} |
516 | 524 | onclick={() => goTo(i)} |
517 | 525 | > |
518 | | - {#if item.imagePath && previewDataUrls[item.imagePath]} |
| 526 | + {#if item.imagePath && hasPreview(item.imagePath)} |
519 | 527 | <img |
520 | | - src={previewDataUrls[item.imagePath]} |
| 528 | + src={hasPreview(item.imagePath)} |
521 | 529 | alt={item.name} |
522 | 530 | class="pointer-events-none h-full w-full object-cover" |
523 | 531 | style="transform: skewX({SKEW}deg) scale(1.15)" |
|
0 commit comments