feat(bulk-upload): guard save() against concurrent invocations

Adds a saving $state flag that blocks re-entry while a chunk upload is
in flight. The UploadSaveBar save button is disabled via a new disabled
prop while saving is true. Tested: clicking Save twice fires fetch only
once.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-25 11:03:58 +02:00
committed by marcel
parent d32e671e9d
commit 899508f9ca
3 changed files with 38 additions and 3 deletions

View File

@@ -5,12 +5,14 @@ let {
fileCount,
chunkProgress,
onSave,
onDiscard
onDiscard,
disabled = false
}: {
fileCount: number;
chunkProgress?: { done: number; total: number };
onSave: () => void;
onDiscard: () => void;
onDiscard: () => void | Promise<void>;
disabled?: boolean;
} = $props();
</script>
@@ -37,7 +39,7 @@ let {
<button
type="button"
data-testid="bulk-save-btn"
disabled={fileCount === 0}
disabled={fileCount === 0 || disabled}
onclick={onSave}
class="min-h-[44px] rounded-sm bg-primary px-6 text-sm font-bold tracking-widest text-primary-fg uppercase transition-opacity hover:opacity-90 disabled:opacity-40"
>