Allow data to be set after save() on a new object without load() calls

After saving a new object and reloading primary data and any changed
data (which we can maybe reconsider at some point), mark all other data
types as loaded, since there's no other data we don't have. For example,
this allows for item.save() to be followed by item.setField() without
needing to call item.loadItemData() first.
This commit is contained in:
Dan Stillman 2015-05-26 04:03:41 -04:00
parent 5d530e4173
commit 3d3b817724
3 changed files with 12 additions and 0 deletions

View file

@ -321,6 +321,10 @@ Zotero.Collection.prototype._finalizeSave = Zotero.Promise.coroutine(function* (
if (!env.skipCache) { if (!env.skipCache) {
yield this.reload(); yield this.reload();
// If new, there's no other data we don't have, so we can mark everything as loaded
if (env.isNew) {
this._markAllDataTypeLoadStates(true);
}
this._clearChanged(); this._clearChanged();
} }

View file

@ -1736,6 +1736,10 @@ Zotero.Item.prototype._finalizeSave = Zotero.Promise.coroutine(function* (env) {
// and not primaryData. // and not primaryData.
yield this.loadPrimaryData(true); yield this.loadPrimaryData(true);
yield this.reload(); yield this.reload();
// If new, there's no other data we don't have, so we can mark everything as loaded
if (env.isNew) {
this._markAllDataTypeLoadStates(true);
}
this._clearChanged(); this._clearChanged();
} }

View file

@ -187,6 +187,10 @@ Zotero.Search.prototype._finalizeSave = Zotero.Promise.coroutine(function* (env)
if (!env.skipCache) { if (!env.skipCache) {
yield this.loadPrimaryData(true); yield this.loadPrimaryData(true);
yield this.reload(); yield this.reload();
// If new, there's no other data we don't have, so we can mark everything as loaded
if (env.isNew) {
this._markAllDataTypeLoadStates(true);
}
this._clearChanged(); this._clearChanged();
} }