commit fdb9e20076f37bf365c78098b8dd69610f3b4e41
parent 2baa537542fcd5bc6e2826eb0eef6b34c571dcfc
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 4 Jan 2018 19:10:41 -0500
Clear parentKey change marker after save
Fixes #1325, Field editor closes during auto-sync of newly created
parent item
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -1623,6 +1623,11 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
yield Zotero.DB.queryAsync(sql, [parentItemID, this.id]);
}
+ // There's no reload for parentKey, so clear it here
+ if (this._changed.parentKey) {
+ this._clearChanged('parentKey');
+ }
+
// Note
if ((isNew && this.isNote()) || this._changed.note) {
if (!isNew) {
diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js
@@ -438,6 +438,18 @@ describe("Zotero.Item", function () {
assert.isFalse(item.hasChanged());
});
+ it("should not be marked as changed after a save", async function () {
+ var item = await createDataObject('item');
+ var attachment = new Zotero.Item('attachment');
+ attachment.attachmentLinkMode = 'linked_url';
+ await attachment.saveTx();
+
+ attachment.parentKey = item.key;
+ assert.isTrue(attachment._changed.parentKey);
+ await attachment.saveTx();
+ assert.isUndefined(attachment._changed.parentKey);
+ });
+
it("should move a top-level note under another item", function* () {
var noteItem = new Zotero.Item('note');
var id = yield noteItem.saveTx()