From 6ce005f882e964d187b37996f2e1911d975b4796 Mon Sep 17 00:00:00 2001 From: Anton SHEPILOV Date: Mon, 22 Jul 2024 15:02:11 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9BFixed=20"folder=20size=20isn't=20di?= =?UTF-8?q?splayed=20after=20the=20upload"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/features/drive/hooks/use-drive-upload.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tdrive/frontend/src/app/features/drive/hooks/use-drive-upload.tsx b/tdrive/frontend/src/app/features/drive/hooks/use-drive-upload.tsx index 33c63afde..e29bfcf03 100644 --- a/tdrive/frontend/src/app/features/drive/hooks/use-drive-upload.tsx +++ b/tdrive/frontend/src/app/features/drive/hooks/use-drive-upload.tsx @@ -55,8 +55,13 @@ export const useDriveUpload = () => { // Upload files into directories logger.debug("Start file uploading") + //create counter to calculate number of uploaded files, and refresh browsing window only when all the files were uploaded + let expectedUploadsCount = 0; + const parentFolder = context.parentId; + let uploadedFilesCount = 0; for (const parentId of Object.keys(filesPerParentId)) { logger.debug(`Upload files for directory ${parentId}`); + expectedUploadsCount += filesPerParentId[parentId].length; await FileUploadService.upload(filesPerParentId[parentId], { context: { companyId: context.companyId, @@ -64,6 +69,7 @@ export const useDriveUpload = () => { }, callback: (file, context) => { logger.debug('created file: ', file); + uploadedFilesCount++; if (file) { create( { @@ -87,10 +93,12 @@ export const useDriveUpload = () => { }, ); } + if (uploadedFilesCount == expectedUploadsCount) { + refresh(parentFolder, true); + } }, }); } - await refresh(context.parentId, true); }; const uploadFromUrl = (