feat(dropzone): emit onUploadComplete callback with created count
Optional callback lets the parent route pop a post-upload banner without lifting state into a store. Dashboard uses it to drive UploadSuccessBanner (issue #296). Only fires when the server actually created new documents — duplicates and errors do not trigger it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,12 @@ import { getErrorMessage } from '$lib/errors';
|
||||
|
||||
const ACCEPTED_TYPES = ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff'];
|
||||
|
||||
interface Props {
|
||||
onUploadComplete?: (count: number) => void;
|
||||
}
|
||||
|
||||
let { onUploadComplete }: Props = $props();
|
||||
|
||||
let isDragging = $state(false);
|
||||
let windowDragging = $state(false);
|
||||
let dragCounter = 0;
|
||||
@@ -80,6 +86,7 @@ async function uploadFiles(files: File[]) {
|
||||
const result = JSON.parse(body);
|
||||
if (result.created?.length > 0) {
|
||||
messages.push({ text: m.upload_success({ count: result.created.length }), isError: false });
|
||||
onUploadComplete?.(result.created.length);
|
||||
}
|
||||
for (const doc of result.updated ?? []) {
|
||||
messages.push({
|
||||
|
||||
Reference in New Issue
Block a user