From 5d610bcad55c5d908a4ae046390124b5f5174762 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Fri, 10 Apr 2026 01:00:45 +0900 Subject: better debug, change button sorting --- src/lib/components/CacheDebug.svelte | 122 ++++++++++++------------------ src/lib/components/CachedThumbnail.svelte | 5 +- src/lib/components/ImageList.svelte | 2 +- src/lib/components/ImagePreview.svelte | 4 +- 4 files changed, 56 insertions(+), 77 deletions(-) (limited to 'src/lib/components') diff --git a/src/lib/components/CacheDebug.svelte b/src/lib/components/CacheDebug.svelte index 09e859d..ea1386d 100644 --- a/src/lib/components/CacheDebug.svelte +++ b/src/lib/components/CacheDebug.svelte @@ -1,11 +1,14 @@ -
- +
+
Cache Debug
- {#if !collapsed && stats !== undefined} + {#if stats !== undefined}
+ +
+ DL Speed: + {#if downloadSpeed > 0} + {formatBytes(downloadSpeed)}/s + {:else} + N/A + {/if} +
+
Memory Cache
Entries: {stats.entries} ({stats.fullCount} full, {stats.thumbCount} thumb)
-
Size: {formatBytes(stats.totalBytes)}
+
Size: {formatBytes(stats.totalBytes)} / {formatBytes(stats.maxBytes)}
+
+ + 90} class:text-warning={budgetPct > 70 && budgetPct <= 90}>{budgetPct.toFixed(1)}% of budget +
@@ -99,46 +93,30 @@
Error: {stats.idbError}
{:else}
Entries: {stats.idbEntries}
-
Size: {formatBytes(stats.idbBytes)}
+
Size: {formatBytes(stats.idbBytes)} / {formatBytes(stats.maxBytes)}
+
+ + 90} class:text-warning={idbBudgetPct > 70 && idbBudgetPct <= 90}>{idbBudgetPct.toFixed(1)}% of budget +
{#if stats.idbWriteErrorCount > 0} -
❌ {stats.idbWriteErrorCount} write errors
+
{stats.idbWriteErrorCount} write errors
{#if stats.idbLastWriteError !== undefined}
{stats.idbLastWriteError}
{/if} {/if}
{#if stats.idbEntries === stats.entries} - ✅ In sync with memory + In sync with memory {:else if stats.idbEntries < stats.entries} - ⏳ IDB behind ({stats.entries - stats.idbEntries} pending) + IDB behind ({stats.entries - stats.idbEntries} pending) {:else} IDB has {stats.idbEntries - stats.entries} extra (pre-loaded) {/if}
{/if}
- -
-
Storage Quota
- {#if storageEstimate !== undefined} -
Used: {formatBytes(storageEstimate.usage)} / {formatBytes(storageEstimate.quota)}
- {#if storageEstimate.quota > 0} - {@const pct = (storageEstimate.usage / storageEstimate.quota * 100)} -
- - 90} class:text-warning={pct > 70 && pct <= 90}>{pct.toFixed(1)}% -
- {/if} - {:else if storageError !== undefined} -
{storageError}
- {:else} -
Querying…
- {/if} -
-
- {:else if !collapsed} -
- {#if refreshing}Loading…{:else}No data{/if}
+ {:else} +
Loading…
{/if}
diff --git a/src/lib/components/CachedThumbnail.svelte b/src/lib/components/CachedThumbnail.svelte index 3a6d452..dada22a 100644 --- a/src/lib/components/CachedThumbnail.svelte +++ b/src/lib/components/CachedThumbnail.svelte @@ -6,9 +6,10 @@ interface Props { path: string; alt: string; + fileDate?: number; } - let { path, alt }: Props = $props(); + let { path, alt, fileDate }: Props = $props(); let blobUrl = $state(undefined); let rawBlobUrl: string | undefined; @@ -56,7 +57,7 @@ try { const { blob, meta } = await flashair.fetchThumbnail(filePath); // Store in cache (fire-and-forget) - void imageCache.put('thumbnail', filePath, blob, meta); + void imageCache.put('thumbnail', filePath, blob, meta, fileDate); const url = URL.createObjectURL(blob); rawBlobUrl = url; blobUrl = url; diff --git a/src/lib/components/ImageList.svelte b/src/lib/components/ImageList.svelte index 5048e1b..d56c95c 100644 --- a/src/lib/components/ImageList.svelte +++ b/src/lib/components/ImageList.svelte @@ -40,7 +40,7 @@ onclick={() => onSelect(file)} > {#if thumbUrl} - + {:else}
🖼️ diff --git a/src/lib/components/ImagePreview.svelte b/src/lib/components/ImagePreview.svelte index 914f9a1..335e231 100644 --- a/src/lib/components/ImagePreview.svelte +++ b/src/lib/components/ImagePreview.svelte @@ -320,7 +320,7 @@ // Check staleness after await if (activePath !== entry.path) return; // Store in cache (fire-and-forget) - void imageCache.put('thumbnail', entry.path, blob, meta); + void imageCache.put('thumbnail', entry.path, blob, meta, entry.date.getTime()); const blobUrl = URL.createObjectURL(blob); rawThumbnailUrl = blobUrl; thumbnailBlobUrl = blobUrl; @@ -386,7 +386,7 @@ const blob = await res.blob(); if (abort.signal.aborted || activePath !== entry.path) return; // Store in cache (fire-and-forget) - void imageCache.put('full', entry.path, blob); + void imageCache.put('full', entry.path, blob, undefined, entry.date.getTime()); autoCacheService.markCached(entry.path); const objectUrl = URL.createObjectURL(blob); rawObjectUrl = objectUrl; -- cgit v1.2.3