mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 18:13:10 +03:00
feat(Upload/Popup): close the popup automatically when the upload is successful
This commit is contained in:
parent
3216e863c9
commit
3ddafb40ec
@ -94,6 +94,7 @@ const useUploadPopup = ({ totalFilesSummary }) => {
|
|||||||
const totalFilesSummaryRef = React.useRef();
|
const totalFilesSummaryRef = React.useRef();
|
||||||
totalFilesSummaryRef.current = totalFilesSummary;
|
totalFilesSummaryRef.current = totalFilesSummary;
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
clearTimeout(timeoutRef.current);
|
||||||
if (!isFinished) return;
|
if (!isFinished) return;
|
||||||
//NOTE(amine): if all the upload items have been canceled, hide the upload popup
|
//NOTE(amine): if all the upload items have been canceled, hide the upload popup
|
||||||
if (totalFilesSummaryRef.current.total === 0) {
|
if (totalFilesSummaryRef.current.total === 0) {
|
||||||
@ -101,8 +102,16 @@ const useUploadPopup = ({ totalFilesSummary }) => {
|
|||||||
resetUploadState();
|
resetUploadState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearTimeout(timeoutRef.current);
|
|
||||||
expandUploadSummary();
|
expandUploadSummary();
|
||||||
|
|
||||||
|
//NOTE(amine): if the upload is successful, automatically close the popup
|
||||||
|
if (totalFilesSummaryRef.current.failed === 0) {
|
||||||
|
timeoutRef.current = setTimeout(() => {
|
||||||
|
hideUploadPopup();
|
||||||
|
resetUploadState();
|
||||||
|
}, 10000);
|
||||||
|
}
|
||||||
}, [isFinished]);
|
}, [isFinished]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,6 +83,7 @@ const useUpload = () => {
|
|||||||
blob: file,
|
blob: file,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
isFinished: false,
|
||||||
totalFiles: prev.totalFiles + 1,
|
totalFiles: prev.totalFiles + 1,
|
||||||
totalBytes: prev.totalBytes + file.size,
|
totalBytes: prev.totalBytes + file.size,
|
||||||
}));
|
}));
|
||||||
|
Loading…
Reference in New Issue
Block a user