Skip to content

Commit

Permalink
Dispatch toasts for upload.
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Nov 26, 2024
1 parent cc5f775 commit f5040e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/langs/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@
"uploading": "Uploading",
"processing": "Processing",
"done": "Done"
}
},
"success": "Upload complete. Your documents will process in the background.",
"error": "Error during upload. See upload list for more details."
},
"authSection": {
"help": {
Expand Down
9 changes: 8 additions & 1 deletion src/lib/components/forms/DocumentUpload.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ progress through the three-part upload process.
import { getCsrfToken } from "$lib/utils/api";
import { getCurrentUser } from "$lib/utils/permissions";
import { getProcessLoader } from "../processing/ProcessContext.svelte";
import { toast } from "../layouts/Toaster.svelte";
export let files: File[] = getFilesToUpload();
export let projects: Project[] = [];
Expand Down Expand Up @@ -202,6 +203,7 @@ progress through the three-part upload process.
// errors are handled within each promise, so we can just wait for all to be settled
await Promise.allSettled(promises);
toast($_("uploadDialog.success"), { status: "success" });
loading = false;
}
Expand All @@ -228,6 +230,7 @@ progress through the three-part upload process.
// bail here on error, console.error to report this to sentry
if (error) {
toast($_("uploadDialog.error"), { status: "error" });
return console.error(error);
}
Expand All @@ -239,7 +242,7 @@ progress through the three-part upload process.
message: "API returned invalid document. Please try again.",
},
};
toast($_("uploadDialog.error"), { status: "error" });
return;
}
Expand All @@ -255,6 +258,7 @@ progress through the three-part upload process.
};
STATUS[id].error = error;
toast($_("uploadDialog.error"), { status: "error" });
return console.error(error);
}
Expand All @@ -263,6 +267,7 @@ progress through the three-part upload process.
status: 500,
message: "Invalid presigned URL",
};
toast($_("uploadDialog.error"), { status: "error" });
return;
}
Expand All @@ -276,6 +281,7 @@ progress through the three-part upload process.
status: 500,
message: "Upload failed",
};
toast($_("uploadDialog.error"), { status: "error" });
return;
}
Expand All @@ -289,6 +295,7 @@ progress through the three-part upload process.
));
if (error) {
toast($_("uploadDialog.error"), { status: "error" });
STATUS[id].error = error;
}
// trigger process load request
Expand Down

0 comments on commit f5040e0

Please sign in to comment.