diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index 61e38fe31f..719aba9900 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -99,24 +99,57 @@ Zotero.Collection.prototype.getName = function() { * Populate collection data from a database row */ Zotero.Collection.prototype.loadFromRow = function(row) { - for each(let col in this.ObjectsClass.primaryFields) { - if (row[col] === undefined) { - Zotero.debug('Skipping missing collection field ' + col); + var primaryFields = this._ObjectsClass.primaryFields; + for (let i=0; i this._changed[dataType]); + if (changed.length == 1 + && changed[0] == 'primaryData' + && this._changed.primaryData.synced + && this._previousData.synced == this._synced) { + return false; + } + return !!changed.length; +} + + /** * Clears log of changed values * @param {String} [dataType] data type/field to clear. Defaults to clearing everything @@ -904,17 +919,6 @@ Zotero.DataObject.prototype.saveTx = function (options) { } -Zotero.DataObject.prototype.hasChanged = function() { - var changed = Object.keys(this._changed).filter(dataType => this._changed[dataType]); - if (changed.length == 1 - && changed[0] == 'primaryData' - && this._changed.primaryData.synced - && this._previousData.synced == this._synced) { - return false; - } - return !!changed.length; -} - Zotero.DataObject.prototype._initSave = Zotero.Promise.coroutine(function* (env) { // Default to user library if not specified if (this.libraryID === null) { diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 952f7c4566..c6f423b222 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -277,8 +277,8 @@ Zotero.DataObjects.prototype.getByLibraryAndKeyAsync = Zotero.Promise.coroutine( }); -Zotero.DataObjects.prototype.exists = function (itemID) { - return !!this.getLibraryAndKeyFromID(itemID); +Zotero.DataObjects.prototype.exists = function (id) { + return !!this.getLibraryAndKeyFromID(id); } @@ -383,7 +383,8 @@ Zotero.DataObjects.prototype.registerObject = function (obj) { var libraryID = obj.libraryID; var key = obj.key; - Zotero.debug("Registering " + this._ZDO_object + " " + id + " as " + libraryID + "/" + key); + Zotero.debug("Registering " + this._ZDO_object + " " + id + + " as " + libraryID + "/" + key); if (!this._objectIDs[libraryID]) { this._objectIDs[libraryID] = {}; } @@ -568,8 +569,7 @@ Zotero.DataObjects.prototype._load = Zotero.Promise.coroutine(function* (library obj = new Zotero[this._ZDO_Object]; obj.loadFromRow(rowObj, true); if (!options || !options.noCache) { - this._objectCache[id] = obj; - obj._inCache = true; + this.registerObject(obj); } } loaded[id] = obj; diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 1cad804d8e..f1a862cee1 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -316,23 +316,26 @@ Zotero.Item.prototype._parseRowData = function(row) { for (let i=0; i