Skip to content

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

core: allow selectively downloading media attachments

Abdullah Attab354a26f0a41
diff --git a/packages/core/collections/attachments.js b/packages/core/collections/attachments.js
index 21753efeb..5b856348e 100644
--- a/packages/core/collections/attachments.js
+++ b/packages/core/collections/attachments.js
@@ -302,12 +302,13 @@ export default class Attachments extends Collection {
return { key, metadata };
}
- async downloadMedia(noteId, attachments) {
- if (!attachments) {
- attachments = this.media.filter((attachment) =>
- hasItem(attachment.noteIds, noteId)
- );
- }
+ async downloadMedia(noteId, hashesToLoad) {
+ const attachments = this.media.filter(
+ (attachment) =>
+ hasItem(attachment.noteIds, noteId) &&
+ (!hashesToLoad || hasItem(hashesToLoad, attachment.metadata.hash))
+ );
+
try {
for (let i = 0; i < attachments.length; i++) {
const attachment = attachments[i];