www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 381fe38b897e57f402465d99fac30892e4130a96
parent 69dec87aa6e1da3ff5554cab2551f00d27e96915
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun, 17 Jul 2016 15:08:52 -0400

Fix #1038,  Notes skip back to beginning if typing during auto-save

Set a unique id on the note editor at initialization and pass it along
to item.saveTx(). When notify() is called, if the save was triggered
from the current note field, don't do a refresh.

This does mean that the note field won't reflect changes (e.g.,
normalizations) made by the save process until the user clicks away and
back, which makes me a little uncomfortable. If we can find specific
cases where that occurs (paste?), we can reevaluate this approach.

Diffstat:
Mchrome/content/zotero/bindings/noteeditor.xml | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml @@ -144,6 +144,7 @@ <constructor> <![CDATA[ + this._instanceID = Zotero.Utilities.randomString(); this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'noteeditor'); ]]> </constructor> @@ -158,6 +159,7 @@ <parameter name="event"/> <parameter name="type"/> <parameter name="ids"/> + <parameter name="extraData"/> <body><![CDATA[ if (event != 'modify' || !this.item || !this.item.id) return; for (let i = 0; i < ids.length; i++) { @@ -165,6 +167,10 @@ if (id != this.item.id) { continue; } + if (extraData && extraData[id] && extraData[id].noteEditorID == this._instanceID) { + //Zotero.debug("Skipping notification from current note field"); + continue; + } this.refresh(); break; } @@ -243,7 +249,11 @@ if (this.item) { let changed = this.item.setNote(noteField.value); if (changed && this.saveOnEdit) { - yield this.item.saveTx(); + yield this.item.saveTx({ + notifierData: { + noteEditorID: this._instanceID + } + }); } return; }