Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: clear download/upload progress on cancel token

ammarahm-ed6d2be3a08313
diff --git a/apps/mobile/app/common/filesystem/download.js b/apps/mobile/app/common/filesystem/download.js
index 1f8323ca5..ce1760a87 100644
--- a/apps/mobile/app/common/filesystem/download.js
+++ b/apps/mobile/app/common/filesystem/download.js
@@ -60,7 +60,10 @@ export async function downloadFile(filename, data, cancelToken) {
console.log("downloading: ", recieved, total);
});
- cancelToken.cancel = request.cancel;
+ cancelToken.cancel = () => {
+ useAttachmentStore.getState().remove(filename);
+ request.cancel();
+ };
let response = await request;
await fileCheck(response, totalSize);
let status = response.info().status;
diff --git a/apps/mobile/app/common/filesystem/upload.js b/apps/mobile/app/common/filesystem/upload.js
index 9fa89f877..a50560558 100644
--- a/apps/mobile/app/common/filesystem/upload.js
+++ b/apps/mobile/app/common/filesystem/upload.js
@@ -72,7 +72,10 @@ export async function uploadFile(filename, data, cancelToken) {
);
});
- cancelToken.cancel = request.cancel;
+ cancelToken.cancel = () => {
+ useAttachmentStore.getState().remove(filename);
+ request.cancel();
+ };
let response = await request;
let status = response.info().status;