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
This commit is contained in:
parent
0ae070970a
commit
3905c98f93
2 changed files with 14 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -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[
|
||||
|
|
Loading…
Reference in a new issue