diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-08-17 19:33:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-17 19:33:53 +0300 |
commit | 6c9ee57d83d30d598062cfa95a73555808e04e7f (patch) | |
tree | dde56a20e1a18b64cc93bc408981a65ee5f7a427 /src/hooks | |
parent | 0a42a6d26fad6d878e4135b218166872c6b6687b (diff) | |
parent | 3b72a38197b1a1cff1c059ed5c55bf9f9d50569d (diff) | |
download | which-ui-6c9ee57d83d30d598062cfa95a73555808e04e7f.tar.gz |
Merge pull request #89 from which-ecosystem/bugs
Bug fixes
Diffstat (limited to 'src/hooks')
-rw-r--r-- | src/hooks/useS3Preupload.tsx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/hooks/useS3Preupload.tsx b/src/hooks/useS3Preupload.tsx index 3c98e9a..3545cd5 100644 --- a/src/hooks/useS3Preupload.tsx +++ b/src/hooks/useS3Preupload.tsx @@ -33,7 +33,8 @@ export default (): Hook => { }, [setUrl, setFile]); const handleUploadProgress = useCallback((progressEvent: ProgressEvent): void => { - setProgress(Math.round((progressEvent.loaded * 100) / progressEvent.total)); + // Only allow upload progress reach 95%, and set 100% when request is resolved + setProgress(Math.round((progressEvent.loaded * 95) / progressEvent.total)); }, [setProgress]); const resolve = useCallback(async (): Promise<string> => { @@ -43,10 +44,12 @@ export default (): Hook => { onUploadProgress: handleUploadProgress }; + setProgress(0.01); return get('/files') .then(response => response.data) .then(uploadUrl => axios.put(uploadUrl, file, config)) .then(response => { + setProgress(100); const uri = response.config.url; return uri ? uri.slice(0, uri.indexOf('?')) : ''; }); |