Fix #1157, Note content lost when typing during sync

Someday, I will say this is fixed and it actually will be fixed.
This commit is contained in:
Dan Stillman 2017-01-19 11:58:43 -05:00
parent e0d92ecd94
commit c95e42240f
2 changed files with 10 additions and 2 deletions

View File

@ -171,6 +171,10 @@
//Zotero.debug("Skipping notification from current note field"); //Zotero.debug("Skipping notification from current note field");
continue; continue;
} }
if (this.noteField.changed) {
//Zotero.debug("Note has changed since last save -- skipping refresh");
return;
}
this.refresh(); this.refresh();
break; break;
} }
@ -181,7 +185,7 @@
<body><![CDATA[ <body><![CDATA[
Zotero.debug('Refreshing note editor'); Zotero.debug('Refreshing note editor');
var textbox = this._id('noteField'); var textbox = this.noteField;
var textboxReadOnly = this._id('noteFieldReadOnly'); var textboxReadOnly = this._id('noteFieldReadOnly');
var button = this._id('goButton'); var button = this._id('goButton');
@ -249,6 +253,7 @@
if (this.item) { if (this.item) {
let changed = this.item.setNote(noteField.value); let changed = this.item.setNote(noteField.value);
if (changed && this.saveOnEdit) { if (changed && this.saveOnEdit) {
this.noteField.changed = false;
yield this.item.saveTx({ yield this.item.saveTx({
notifierData: { notifierData: {
noteEditorID: this._instanceID noteEditorID: this._instanceID

View File

@ -429,6 +429,7 @@
//Zotero.debug("Not a char"); //Zotero.debug("Not a char");
return; return;
} }
this._changed = true;
commandEvent = true; commandEvent = true;
break; break;
@ -436,6 +437,7 @@
case 'change': case 'change':
case 'undo': case 'undo':
case 'redo': case 'redo':
this._changed = true;
commandEvent = true; commandEvent = true;
break; break;
@ -524,6 +526,7 @@
if (this.value == val) { if (this.value == val) {
Zotero.debug("Textbox value hasn't changed"); Zotero.debug("Textbox value hasn't changed");
this._changed = false;
return; return;
} }
@ -570,7 +573,7 @@
onset="this.setAttribute('timeout', val); return val;" onset="this.setAttribute('timeout', val); return val;"
onget="return parseInt(this.getAttribute('timeout')) || 0;"/> onget="return parseInt(this.getAttribute('timeout')) || 0;"/>
<property name="changed" onget="return this._changed;"/> <property name="changed" onget="return this._changed;" onset="this._changed = !!val;"/>
<method name="focus"> <method name="focus">
<body> <body>