commit 3905c98f931cd174dc651604a3a56173674e6d1f
parent 0ae070970ab179a724ab734bcf9fb3fb64b7f007
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 22 May 2016 23:09:41 -0400
Don't save note if it hasn't been changed by user
After uploading a note to the API, the local version may be overwritten with
the sanitized version in the API write response. This commit prevents the note
from being resaved when the note is clicked, reformatted by TinyMCE, and
clicked away from, which would result in an endless resync cycle. Instead, the
note is only resaved (and marked for syncing) when the user manually makes a
change.
Please enter the commit message for your changes. Lines starting
Diffstat:
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml
@@ -240,6 +240,11 @@
// Update note
var noteField = this._id('noteField');
if (this.item) {
+ if (!noteField.changed) {
+ Zotero.debug("Note hasn't been modified -- not saving");
+ return;
+ }
+
let changed = this.item.setNote(noteField.value);
if (changed && this.saveOnEdit) {
yield this.item.saveTx();
diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml
@@ -34,6 +34,7 @@
<field name="_editable"/>
<field name="_mode"/>
<field name="_format"/>
+ <field name="_changed"/>
<field name="_loadHandler"/>
<field name="_commandString"/>
<field name="_eventHandler"/>
@@ -425,6 +426,10 @@
clearTimeout(self._timer);
}
+ if (event.type == 'change') {
+ self._changed = true;
+ }
+
// Get the command event
self._timer = self.timeout && setTimeout(function () {
var attr = self.getAttribute('oncommand');
@@ -534,9 +539,10 @@
html = '<div style="'+bodyStyle+'"><p>'+html+"</p></div>";
}
- Zotero.debug("SETTING CONTENT TO " + html);
+ Zotero.debug("Setting content to " + html);
this._editor.setContent(html);
+ this._changed = false;
return val;
]]></setter>
</property>
@@ -545,6 +551,8 @@
onset="this.setAttribute('timeout', val); return val;"
onget="return parseInt(this.getAttribute('timeout')) || 0;"/>
+ <property name="changed" onget="return this._changed;"/>
+
<method name="focus">
<body>
<![CDATA[