Skip to content

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

core: merge remote attachment if local attachment doesn't exist

Abdullah Atta308eb4b55fee
diff --git a/packages/core/src/collections/attachments.js b/packages/core/src/collections/attachments.js
index 0a5d9a167..f42a3db57 100644
--- a/packages/core/src/collections/attachments.js
+++ b/packages/core/src/collections/attachments.js
@@ -39,7 +39,10 @@ export default class Attachments extends Collection {
merge(localAttachment, remoteAttachment) {
if (remoteAttachment.deleted) return remoteAttachment;
- if (remoteAttachment.dateModified > localAttachment.dateModified)
+ if (
+ !localAttachment ||
+ remoteAttachment.dateModified > localAttachment.dateModified
+ )
return remoteAttachment;
if (localAttachment && localAttachment.noteIds) {