Fix annotation image saving to cache for read-only annotations
(cherry picked from commit 28329aa785
)
This commit is contained in:
parent
b851e66ec8
commit
35cbbeeea4
1 changed files with 15 additions and 12 deletions
|
@ -1034,19 +1034,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue