diff --git a/chrome/content/zotero/xpcom/api.js b/chrome/content/zotero/xpcom/api.js index 39f5b5f39b..81229692f3 100644 --- a/chrome/content/zotero/xpcom/api.js +++ b/chrome/content/zotero/xpcom/api.js @@ -130,7 +130,7 @@ Zotero.API = { // Filter results by item key if (params.itemKey) { ids = ids.filter(function (id) { - var [libraryID, key] = Zotero.Items.getLibraryAndKeyFromID(id); + var {libraryID, key} = Zotero.Items.getLibraryAndKeyFromID(id); return params.itemKey.indexOf(key) !== -1; }); } diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index fe77a6cda1..f4d2d83196 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -50,7 +50,8 @@ Zotero.Attachments = new function(){ // Create a new attachment var attachmentItem = new Zotero.Item('attachment'); if (parentItemID) { - let [parentLibraryID, parentKey] = Zotero.Items.getLibraryAndKeyFromID(parentItemID); + let {libraryID: parentLibraryID, key: parentKey} = + Zotero.Items.getLibraryAndKeyFromID(parentItemID); attachmentItem.libraryID = parentLibraryID; } else if (libraryID) { @@ -151,7 +152,7 @@ Zotero.Attachments = new function(){ yield Zotero.DB.executeTransaction(function* () { // Create a new attachment var attachmentItem = new Zotero.Item('attachment'); - let [libraryID, parentKey] = Zotero.Items.getLibraryAndKeyFromID(parentItemID); + let {libraryID, key: parentKey} = Zotero.Items.getLibraryAndKeyFromID(parentItemID); attachmentItem.libraryID = libraryID; attachmentItem.setField('title', title); attachmentItem.setField('url', url); @@ -318,7 +319,8 @@ Zotero.Attachments = new function(){ attachmentItem.libraryID = libraryID; } else if (parentItemID) { - let [parentLibraryID, parentKey] = Zotero.Items.getLibraryAndKeyFromID(parentItemID); + let {libraryID: parentLibraryID, key: parentKey} = + Zotero.Items.getLibraryAndKeyFromID(parentItemID); attachmentItem.libraryID = parentLibraryID; } attachmentItem.setField('title', title ? title : fileName); @@ -627,7 +629,8 @@ Zotero.Attachments = new function(){ attachmentItem.libraryID = libraryID; } else if (parentItemID) { - let [parentLibraryID, parentKey] = Zotero.Items.getLibraryAndKeyFromID(parentItemID); + let {libraryID: parentLibraryID, key: parentKey} = + Zotero.Items.getLibraryAndKeyFromID(parentItemID); Zotero.debug('==-='); Zotero.debug(parentItemID); Zotero.debug(parentLibraryID); @@ -862,7 +865,7 @@ Zotero.Attachments = new function(){ if (!itemID) { throw new Error("itemID not provided"); } - var [libraryID, key] = Zotero.Items.getLibraryAndKeyFromID(itemID); + var {libraryID, key} = Zotero.Items.getLibraryAndKeyFromID(itemID); if (!key) { throw new Error("Item " + itemID + " not found"); } @@ -1287,7 +1290,8 @@ Zotero.Attachments = new function(){ return Zotero.DB.executeTransaction(function* () { var attachmentItem = new Zotero.Item('attachment'); if (parentItemID) { - let [parentLibraryID, parentKey] = Zotero.Items.getLibraryAndKeyFromID(parentItemID); + let {libraryID: parentLibraryID, key: parentKey} = + Zotero.Items.getLibraryAndKeyFromID(parentItemID); if (parentLibraryID && linkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE) { throw new Error("Cannot save linked file in non-local library"); } diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js index d2d74eec0e..802a2fdcd5 100644 --- a/chrome/content/zotero/xpcom/data/dataObject.js +++ b/chrome/content/zotero/xpcom/data/dataObject.js @@ -161,7 +161,7 @@ Zotero.DataObject.prototype._getParentID = function () { Zotero.DataObject.prototype._setParentID = function (id) { return this._setParentKey( id - ? this.ObjectsClass.getLibraryAndKeyFromID(Zotero.DataObjectUtilities.checkDataID(id))[1] + ? this.ObjectsClass.getLibraryAndKeyFromID(Zotero.DataObjectUtilities.checkDataID(id)).key : null ); } diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index d2c71d7e7c..049a7e4677 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -270,10 +270,11 @@ Zotero.DataObjects.prototype.exists = function (itemID) { /** - * @return {Array} Array with libraryID and key + * @return {Object} Object with 'libraryID' and 'key' */ Zotero.DataObjects.prototype.getLibraryAndKeyFromID = function (id) { - return this._objectKeys[id] ? this._objectKeys[id] : false; + var lk = this._objectKeys[id]; + return lk ? { libraryID: lk[0], key: lk[1] } : false; } @@ -413,7 +414,7 @@ Zotero.DataObjects.prototype.unload = function () { var ids = Zotero.flattenArguments(arguments); for (var i=0; i