Mark all data as loaded when loading primary data for nonexistent object

This commit is contained in:
Dan Stillman 2015-04-16 16:44:16 -04:00
parent 293f7c6dd4
commit 0154e44c2f

View file

@ -47,9 +47,7 @@ Zotero.DataObject = function () {
this._identified = false; this._identified = false;
this._loaded = {}; this._loaded = {};
for (let i=0; i<this._dataTypes.length; i++) { this._markAllDataTypeLoadStates(false);
this._loaded[this._dataTypes[i]] = false;
}
this._clearChanged(); this._clearChanged();
}; };
@ -372,8 +370,11 @@ Zotero.DataObject.prototype.loadPrimaryData = Zotero.Promise.coroutine(function*
throw new Error(this._ObjectType + " " + (id ? id : libraryID + "/" + key) throw new Error(this._ObjectType + " " + (id ? id : libraryID + "/" + key)
+ " not found in Zotero." + this._ObjectType + ".loadPrimaryData()"); + " not found in Zotero." + this._ObjectType + ".loadPrimaryData()");
} }
this._loaded.primaryData = true;
this._clearChanged('primaryData'); this._clearChanged('primaryData');
// If object doesn't exist, mark all data types as loaded
this._markAllDataTypeLoadStates(true);
return; return;
} }
@ -457,6 +458,12 @@ Zotero.DataObject.prototype.loadAllData = function (reload) {
return Zotero.Promise.all(loadPromises); return Zotero.Promise.all(loadPromises);
} }
Zotero.DataObject.prototype._markAllDataTypeLoadStates = function (loaded) {
for (let i = 0; i < this._dataTypes.length; i++) {
this._loaded[this._dataTypes[i]] = loaded;
}
}
/** /**
* Save old version of data that's being changed, to pass to the notifier * Save old version of data that's being changed, to pass to the notifier
* @param {String} field * @param {String} field