From c5d418fc16347d7aa7f61273afb7222112c3860a Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Thu, 6 Oct 2022 16:43:58 +0300 Subject: [PATCH] Fix annotation saving regression --- chrome/content/zotero/xpcom/reader.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index 68c40a4ebb..dfa6cbf358 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -1028,24 +1028,20 @@ class ReaderInstance { saveOptions.notifierData.autoSyncDelay = Zotero.Notes.AUTO_SYNC_DELAY; } - // Note: annotation.image is always saved separately from the rest - // of annotation properties - if (annotation.image) { - if (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); - } - } - else { - // Delete authorName to prevent overwriting the existing annotationAuthorName value - delete annotation.authorName; - let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions); + 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(savedAnnotation, blob); + 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 blob = this._dataURLtoBlob(annotation.image); + await Zotero.Annotations.saveCacheImage(savedAnnotation, blob); + } } } finally {