Skip to content

Commit

Permalink
fix for cancel upload
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Jul 2, 2023
1 parent 34113c3 commit 86daa13
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/react-router-dom": "^5.3.3",
"alova": "^2.8.1",
"alova": "^2.9.0",
"async-validator": "^4.2.5",
"history": "^5.3.0",
"jwt-decode": "^3.1.2",
Expand Down
3 changes: 2 additions & 1 deletion interface/src/api/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export const alovaInstance = createAlova({
}

// Interceptor for request failure. This interceptor will be entered when the request is wrong.
// TODO how best to handle http errors like 401 (unauthorized) but I think this is handled correctly in AppRouting?
// TODO how best to handle http errors like 401 (unauthorized)
// but I think this is handled correctly in AppRouting? See AuthenticatedRouting()
// onError: (error, method) => {
// alert(error.message);
// }
Expand Down
16 changes: 8 additions & 8 deletions interface/src/framework/system/UploadFileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const UploadFileForm: FC = () => {
uploading: progress,
send: sendUpload,
onSuccess: onSuccessUpload,
abort
abort: cancelUpload
} = useRequest(SystemApi.uploadFile, {
immediate: false,
force: true
Expand All @@ -49,14 +49,14 @@ const UploadFileForm: FC = () => {
}
});

const cancelUpload = () => {
console.log('aborting upload...'); // TODO remove debug
abort();
toast.warning(LL.UPLOAD() + ' ' + LL.ABORTED());
};

const startUpload = async (files: File[]) => {
await sendUpload(files[0]);
await sendUpload(files[0]).catch((err) => {
if (err.message === 'The user aborted a request') {
toast.warning(LL.UPLOAD() + ' ' + LL.ABORTED());
} else {
toast.warning(err.message);
}
});
};

const saveFile = (json: any, endpoint: string) => {
Expand Down
10 changes: 5 additions & 5 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ __metadata:
"@typescript-eslint/eslint-plugin": ^5.60.1
"@typescript-eslint/parser": ^5.60.1
"@vitejs/plugin-react-swc": ^3.3.2
alova: ^2.8.1
alova: ^2.9.0
async-validator: ^4.2.5
eslint: ^8.44.0
eslint-config-airbnb: ^19.0.4
Expand Down Expand Up @@ -1629,10 +1629,10 @@ __metadata:
languageName: node
linkType: hard

"alova@npm:^2.8.1":
version: 2.8.1
resolution: "alova@npm:2.8.1"
checksum: 28b6ce7f45ac1d9a38b35e92db7886c3ba899cc54109f239dc590f38da9cb0ccbc650c0455b7e3f08bbd0d714e3e4fa19648342536ceae0cd8f4898f1d9f9b64
"alova@npm:^2.9.0":
version: 2.9.0
resolution: "alova@npm:2.9.0"
checksum: 397317cbc222cf732b03dc667b7540ccd1be7013d3b4940bc9e9b11657ffbbdf297a056df4203042a8554b4f9deab3e9e6d6af2e6012b69c07b63b65734d2a7e
languageName: node
linkType: hard

Expand Down
3 changes: 1 addition & 2 deletions mock-api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function progress_middleware(req, res, next) {
const percentage = (progress / file_size) * 100;
console.log(`Progress: ${Math.round(percentage)}%`);
// await delay(1000); // slow it down
delay_blocking(100); // slow it down
delay_blocking(200); // slow it down
});
next(); // invoke next middleware which is multer
}
Expand Down Expand Up @@ -2058,7 +2058,6 @@ rest_server.get(LIST_NETWORKS_ENDPOINT, (req, res) => {
res.sendStatus(200); // waiting....
}
});
// TODO should be a post as its a command?
rest_server.get(SCAN_NETWORKS_ENDPOINT, (req, res) => {
console.log('start scan networks');
countWifiScanPoll = 0; // stop the poll
Expand Down

0 comments on commit 86daa13

Please sign in to comment.