Skip to content

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

mobile: show error if attachment download fails

Ammar Ahmed1dbd2d8f5f61
diff --git a/apps/mobile/app/common/filesystem/download-attachment.js b/apps/mobile/app/common/filesystem/download-attachment.js
index 2178b38a0..1f0455e5b 100644
--- a/apps/mobile/app/common/filesystem/download-attachment.js
+++ b/apps/mobile/app/common/filesystem/download-attachment.js
@@ -84,8 +84,10 @@ export async function downloadAttachments(
Platform.OS === "ios"
? `${outputFolder}/notesnook-attachments-${Date.now()}.zip`
: `${cacheDir}/notesnook-attachments.zip`;
- if (await RNFetchBlob.fs.exists(zipSourceFolder))
+ if (await RNFetchBlob.fs.exists(zipSourceFolder)) {
await RNFetchBlob.fs.unlink(zipSourceFolder);
+ }
+
await RNFetchBlob.fs.mkdir(zipSourceFolder);
for (let i = 0; i < attachments.length; i++) {
@@ -127,7 +129,7 @@ export async function downloadAttachments(
status: FileDownloadStatus.Fail,
reason: e
});
- console.log("Error downloading attachment", e);
+ ToastManager.error(e, "Error downloading attachment");
}
}
if (canceled.current) {
@@ -164,7 +166,7 @@ export async function downloadAttachments(
} catch (e) {
releasePermissions(outputFolder);
sub?.remove();
- console.log("Error zipping attachments", e);
+ ToastManager.error(e, "Error zipping attachments");
}
// Remove source & zip file from cache.
RNFetchBlob.fs.unlink(zipSourceFolder).catch(console.log);
diff --git a/apps/mobile/app/components/attachments/download-attachments.tsx b/apps/mobile/app/components/attachments/download-attachments.tsx
index 1a8bb33b6..b66995efd 100644
--- a/apps/mobile/app/components/attachments/download-attachments.tsx
+++ b/apps/mobile/app/components/attachments/download-attachments.tsx
@@ -84,8 +84,9 @@ const DownloadAttachments = ({
canceled.current = true;
if (!groupId.current) return;
console.log(groupId.current, "canceling groupId downloads");
- await db.fs().cancel(groupId.current, "download");
+ await db.fs().cancel(groupId.current);
setDownloading(false);
+ setResult(new Map());
groupId.current = undefined;
};
@@ -201,7 +202,7 @@ const DownloadAttachments = ({
</Paragraph>
</View>
}
- keyExtractor={(index) => "attachment" + index}
+ keyExtractor={(index) => "attachment_download" + index}
renderItem={({ index }) => {
return (
<AttachmentItem