diff --git a/frontend/src/components/Modals/ManageWorkspace/Documents/UploadFile/index.jsx b/frontend/src/components/Modals/ManageWorkspace/Documents/UploadFile/index.jsx index 01d79dd125836384c9873d50135d93b65e38ce0e..4dd04b023a3d55d16ddb3a284293418702a5e696 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) => {