From 3d3b81772401f5cfb645ca6913284405d8c572ed Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 26 May 2015 04:03:41 -0400 Subject: [PATCH] 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. --- chrome/content/zotero/xpcom/data/collection.js | 4 ++++ chrome/content/zotero/xpcom/data/item.js | 4 ++++ chrome/content/zotero/xpcom/search.js | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index 267b13e9ef..7d3aafe619 100644 --- 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 index 1fcc4a7983..78405e73cc 100644 --- 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 index f904d5f573..2b5e4a3f8d 100644 --- 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(); }