Don't try to modify non-editable annotation item when saving image

This commit is contained in:
Martynas Bagdonas 2022-03-15 11:04:02 +02:00
parent 769bfbc892
commit d4339f20bd

View file

@ -649,6 +649,22 @@ class ReaderInstance {
instanceID: this._instanceID
}
};
// Note: annotation.image is always saved separately from the rest
// of annotation properties
let item = Zotero.Items.getByLibraryAndKey(attachment.libraryID, annotation.key);
// Save image for read-only annotation.
if (item
&& !item.isEditable()
&& annotation.image
&& !await Zotero.Annotations.hasCacheImage(item)
) {
let blob = this._dataURLtoBlob(annotation.image);
await Zotero.Annotations.saveCacheImage(item, blob);
continue;
}
let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions);
if (annotation.image && !await Zotero.Annotations.hasCacheImage(savedAnnotation)) {
let blob = this._dataURLtoBlob(annotation.image);