fix(library): fix RAW develop fallback & optimize STUDIO to LIBRARY transition speed

This commit is contained in:
2026-10-06 13:24:20 +07:00
parent 2e1feb195a
commit 5db943ddd5
5 changed files with 9 additions and 11 deletions
+1 -7
View File
@@ -562,13 +562,7 @@ export function Library() {
keep(VIEW_KEY, view);
}, [view]);
// Clear global memory caches when leaving Library screen
useEffect(() => {
return () => {
shots.clear();
clearLibraryCache();
};
}, []);
// Keep global memory caches in RAM during SPA tab navigation between STUDIO and LIBRARY
// The menu closes on the next click anywhere but its own items, and on Escape.
// Escape is the whole reason this listens on the document instead of sitting
+2 -2
View File
@@ -893,8 +893,8 @@ export async function scanFolder(
}
const raw = isRawName(file.name);
const isTiff = /\.(tiff?)$/i.test(file.name);
const RAW_HEADER_BYTES = 4 * 1024 * 1024;
const sliceBuffer = await file.slice(0, (raw || isTiff) ? (isTiff ? Math.min(file.size, 16 * 1024 * 1024) : RAW_HEADER_BYTES) : HEAD_BYTES).arrayBuffer();
const RAW_HEADER_BYTES = 16 * 1024 * 1024;
const sliceBuffer = await file.slice(0, (raw || isTiff) ? Math.min(file.size, RAW_HEADER_BYTES) : HEAD_BYTES).arrayBuffer();
const bytes = new Uint8Array(sliceBuffer);
const preview = (raw || isTiff) ? await rawThumbnail(bytes, file.name) : null;
const src = preview ? new Blob([preview as BlobPart], { type: 'image/jpeg' }) : raw ? null : file;
+5 -1
View File
@@ -664,8 +664,12 @@ export async function developRaw(bytes: Uint8Array): Promise<Uint8Array> {
// The preview still opens the file when the sensor will not: a RAW whose
// colour data is missing (some DNG) is not a RAW that cannot be shown.
if (preview) return preview;
const fallback = await rawThumbnail(bytes).catch(() => null);
if (fallback) return fallback;
throw err;
} finally {
raw.dispose();
try {
raw.dispose();
} catch {}
}
}