perf: reuse preview on apply instead of reprocessing

Pass the already-processed preview data URL when applying edits.
The thumbnail updates instantly without triggering another process cycle.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-05-14 07:10:00 -04:00
parent dbb896e2b7
commit e37dd6f25d
2 changed files with 10 additions and 4 deletions

View File

@@ -11,7 +11,7 @@
image: ImageEntry | null;
device: Device;
onClose: () => void;
onApply: (imageId: string, config: PipelineConfig) => void;
onApply: (imageId: string, config: PipelineConfig, processedDataUrl: string | null) => void;
}
let { open, image, device, onClose, onApply }: Props = $props();
@@ -36,7 +36,7 @@
function handleApply(): void {
if (!image) return;
onApply(image.id, localConfig);
onApply(image.id, localConfig, previewDataUrl);
onClose();
}

View File

@@ -89,9 +89,15 @@
editingImage = null;
}
function handleApplyPipeline(imageId: string, config: PipelineConfig): void {
function handleApplyPipeline(imageId: string, config: PipelineConfig, processedDataUrl: string | null): void {
imagesStore.setPipelineOverride(imageId, config);
imagesStore.reprocessImage(imageId, deviceStore.selected);
if (processedDataUrl) {
// Use the already-processed preview directly
imagesStore.updateImage(imageId, { processedDataUrl });
} else {
// Fallback: reprocess if no preview available
imagesStore.reprocessImage(imageId, deviceStore.selected);
}
}
function handleClearAll(): void {