Accept non-integer attachmentLastPageIndex

This commit is contained in:
Abe Jellinek 2023-05-12 22:30:01 +03:00
parent c9c7805cdf
commit c9381f307c

View file

@ -3409,7 +3409,7 @@ Zotero.Item.prototype.getAttachmentLastPageIndex = function () {
var id = this._getLastPageIndexSettingKey(); var id = this._getLastPageIndexSettingKey();
var val = Zotero.SyncedSettings.get(Zotero.Libraries.userLibraryID, id); var val = Zotero.SyncedSettings.get(Zotero.Libraries.userLibraryID, id);
if (val !== null && (typeof val != 'number' || val != parseInt(val))) { if (this.isPDFAttachment() && val !== null && (typeof val != 'number' || val != parseInt(val))) {
Zotero.logError(`Setting contains an invalid attachment page index ('${val}') -- discarding`); Zotero.logError(`Setting contains an invalid attachment page index ('${val}') -- discarding`);
return null; return null;
} }
@ -3421,7 +3421,7 @@ Zotero.Item.prototype.setAttachmentLastPageIndex = async function (val) {
throw new Error("setAttachmentLastPageIndex() can only be called on file attachments"); throw new Error("setAttachmentLastPageIndex() can only be called on file attachments");
} }
if (typeof val != 'number' || val != parseInt(val)) { if (this.isPDFAttachment() && (typeof val != 'number' || val != parseInt(val))) {
Zotero.debug(val, 2); Zotero.debug(val, 2);
throw new Error(`setAttachmentLastPageIndex() must be passed an integer`); throw new Error(`setAttachmentLastPageIndex() must be passed an integer`);
} }