From 4b953492a50487195be3ae452773ad3068167908 Mon Sep 17 00:00:00 2001 From: timothycarambat <rambat1010@gmail.com> Date: Fri, 31 Jan 2025 13:49:32 -0800 Subject: [PATCH] Fix inifite loading when bad file is uploaded alone in uploader --- .../Modals/ManageWorkspace/Documents/UploadFile/index.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Modals/ManageWorkspace/Documents/UploadFile/index.jsx b/frontend/src/components/Modals/ManageWorkspace/Documents/UploadFile/index.jsx index 01d79dd12..4dd04b023 100644 --- a/frontend/src/components/Modals/ManageWorkspace/Documents/UploadFile/index.jsx +++ b/frontend/src/components/Modals/ManageWorkspace/Documents/UploadFile/index.jsx @@ -40,9 +40,11 @@ export default function UploadFile({ setFetchingUrl(false); }; - // Don't spam fetchKeys, wait 1s between calls at least. - const handleUploadSuccess = debounce(() => fetchKeys(true), 1000); - const handleUploadError = (_msg) => null; // stubbed. + // Queue all fetchKeys calls through the same debouncer to prevent spamming the server. + // either a success or error will trigger a fetchKeys call so the UI is not stuck loading. + const debouncedFetchKeys = debounce(() => fetchKeys(true), 1000); + const handleUploadSuccess = () => debouncedFetchKeys(); + const handleUploadError = () => debouncedFetchKeys(); const onDrop = async (acceptedFiles, rejections) => { const newAccepted = acceptedFiles.map((file) => { -- GitLab