commit 3d3b81772401f5cfb645ca6913284405d8c572ed
parent 5d530e41737ca392da08b9842bd4a79bdba5cbf7
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 26 May 2015 04:03:41 -0400
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.
Diffstat:
3 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js
@@ -321,6 +321,10 @@ Zotero.Collection.prototype._finalizeSave = Zotero.Promise.coroutine(function* (
if (!env.skipCache) {
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();
}
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -1736,6 +1736,10 @@ Zotero.Item.prototype._finalizeSave = Zotero.Promise.coroutine(function* (env) {
// and not primaryData.
yield this.loadPrimaryData(true);
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();
}
diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js
@@ -187,6 +187,10 @@ Zotero.Search.prototype._finalizeSave = Zotero.Promise.coroutine(function* (env)
if (!env.skipCache) {
yield this.loadPrimaryData(true);
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();
}