diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index dfa6cbf358..ea19499e28 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -1028,19 +1028,22 @@ class ReaderInstance { saveOptions.notifierData.autoSyncDelay = Zotero.Notes.AUTO_SYNC_DELAY; } - if (annotation.image && this._isReadOnly()) { - let item = Zotero.Items.getByLibraryAndKey(attachment.libraryID, annotation.key); - if (item) { - let blob = this._dataURLtoBlob(annotation.image); - await Zotero.Annotations.saveCacheImage(item, blob); - } - } - // Delete authorName to prevent setting annotationAuthorName unnecessarily - delete annotation.authorName; - let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions); - if (annotation.image) { + let item = Zotero.Items.getByLibraryAndKey(attachment.libraryID, annotation.key); + // If annotation isn't editable, only save image to cache. + // This is the only case when saving can be triggered for non-editable annotation + if (annotation.image && item && !item.isEditable()) { let blob = this._dataURLtoBlob(annotation.image); - await Zotero.Annotations.saveCacheImage(savedAnnotation, blob); + await Zotero.Annotations.saveCacheImage(item, blob); + } + // Save annotation, and save image to cache + else { + // Delete authorName to prevent setting annotationAuthorName unnecessarily + delete annotation.authorName; + let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions); + if (annotation.image) { + let blob = this._dataURLtoBlob(annotation.image); + await Zotero.Annotations.saveCacheImage(savedAnnotation, blob); + } } } }