Skip to content

Commit

Permalink
chore: Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund committed Nov 8, 2023
1 parent 9afaa08 commit 63ada81
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3,272 deletions.
31 changes: 0 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"react-scripts": "5.0.1",
"styled-components": "^5.3.9",
"typescript": "^4.9.4",
"uuid": "^9.0.1",
"web-vitals": "^2.1.0",
"zod": "^3.22.4"
},
Expand Down Expand Up @@ -64,7 +63,6 @@
"devDependencies": {
"@tanstack/eslint-plugin-query": "^4.32.5",
"@types/styled-components": "^5.1.26",
"@types/uuid": "^9.0.6",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
Expand Down
23 changes: 10 additions & 13 deletions src/pages/Browse/Browse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import MetadataProps, {
} from '../../features/AddModel/AddModelDialog/AddModelDialog';
import * as Styled from './Browse.styled';

const chunkSize = 1024 * 1024 * 99; // its 3MB, increase the number measure in mb
enum UploadProcess {
STARTED = 'We are uploading your new model. Please keep this browser tab open.',
SUCCESS = 'Model successfully uploaded. You may close this browser tab now.',
Expand All @@ -30,12 +29,12 @@ enum UploadProcess {

export const Browse = () => {
const [progress, setProgress] = useState(0);

const [counter, setCounter] = useState(1);
const [fileToBeUpload, setFileToBeUpload] = useState<File>();
const [beginingOfTheChunk, setBeginingOfTheChunk] = useState(0);
const [endOfTheChunk, setEndOfTheChunk] = useState(chunkSize);
const [endOfTheChunk, setEndOfTheChunk] = useState<number>();
const [fileSize, setFileSize] = useState(0);
const [chunkSize, setChunkSize] = useState(0);
const [chunkCount, setChunkCount] = useState(0);
const [modelId, setModelId] = useState<string>('');
const [uploadId, setUploadId] = useState<string>('');
Expand Down Expand Up @@ -100,19 +99,16 @@ export const Browse = () => {

const createManifest = await modelManifest.mutateAsync(data);
if (modelManifest.error === null && createManifest.success) {
const chunkSize = createManifest.data.fileSize;
const uploadId = createManifest.data.uploadId;
const recivedChunkSize = createManifest.data.fileSize;
const numberOfChunks = createManifest.data.numChunks;
setUploadId(uploadId);
setChunkSize(recivedChunkSize);
setEndOfTheChunk(recivedChunkSize);
setChunkCount(numberOfChunks);
setFileToBeUpload(file);
setFileSize(file.size);

const _file = file;
setFileSize(_file.size);
const _totalCount =
_file.size % chunkSize === 0
? _file.size / chunkSize
: Math.floor(_file.size / chunkSize) + 1; // Total count of chunks will have been upload to finish the file
setChunkCount(_totalCount);

setFileToBeUpload(_file);
toggleDialog();
}
}
Expand Down Expand Up @@ -141,6 +137,7 @@ export const Browse = () => {
const uploadChunks = await chunkUpload.mutateAsync(chunkData);

if (chunkUpload.error === null && uploadChunks.success) {
if (endOfTheChunk === undefined) return;
setBeginingOfTheChunk(endOfTheChunk);
setEndOfTheChunk(endOfTheChunk + chunkSize);
if (counter === chunkCount) {
Expand Down
Loading

0 comments on commit 63ada81

Please sign in to comment.