diff --git a/chrome/content/zotero/bindings/oldnoteeditor.xml b/chrome/content/zotero/bindings/oldnoteeditor.xml
index 35f8af0c3c..36e784d49b 100644
--- a/chrome/content/zotero/bindings/oldnoteeditor.xml
+++ b/chrome/content/zotero/bindings/oldnoteeditor.xml
@@ -276,6 +276,7 @@
this.noteField.changed = false;
yield this.item.saveTx({
notifierData: {
+ autoSyncDelay: Zotero.Notes.AUTO_SYNC_DELAY,
noteEditorID: this.instanceID
}
});
@@ -293,7 +294,11 @@
item.parentKey = this.parentItem.key;
}
if (this.saveOnEdit) {
- var id = yield item.saveTx();
+ var id = yield item.saveTx({
+ notifierData: {
+ autoSyncDelay: Zotero.Notes.AUTO_SYNC_DELAY
+ }
+ });
if (!this.parentItem && this.collection) {
this.collection.addItem(id);
diff --git a/chrome/content/zotero/xpcom/data/notes.js b/chrome/content/zotero/xpcom/data/notes.js
index 5bfb1925d1..0f16521886 100644
--- a/chrome/content/zotero/xpcom/data/notes.js
+++ b/chrome/content/zotero/xpcom/data/notes.js
@@ -25,13 +25,14 @@
Zotero.Notes = new function() {
- this._editorInstances = [];
-
+ this.AUTO_SYNC_DELAY = 15;
this.__defineGetter__("MAX_TITLE_LENGTH", function() { return 120; });
this.__defineGetter__("defaultNote", function () { return '
'; });
this.__defineGetter__("notePrefix", function () { return ''; });
this.__defineGetter__("noteSuffix", function () { return '
'; });
+ this._editorInstances = [];
+
/**
* Return first line (or first MAX_LENGTH characters) of note content
**/
diff --git a/chrome/content/zotero/xpcom/editorInstance.js b/chrome/content/zotero/xpcom/editorInstance.js
index a77de442e5..d02e977584 100644
--- a/chrome/content/zotero/xpcom/editorInstance.js
+++ b/chrome/content/zotero/xpcom/editorInstance.js
@@ -808,6 +808,8 @@ class EditorInstance {
await this._item.save({
skipDateModifiedUpdate,
notifierData: {
+ // Use a longer timeout to avoid repeated syncing during typing
+ autoSyncDelay: Zotero.Notes.AUTO_SYNC_DELAY,
noteEditorID: this.instanceID,
state
}
@@ -826,7 +828,11 @@ class EditorInstance {
item.parentKey = this.parentItem.key;
}
if (!this._disableSaving) {
- var id = await item.saveTx();
+ var id = await item.saveTx({
+ notifierData: {
+ autoSyncDelay: Zotero.Notes.AUTO_SYNC_DELAY
+ }
+ });
if (!this.parentItem && this.collection) {
this.collection.addItem(id);
}
diff --git a/chrome/content/zotero/xpcom/sync/syncEventListeners.js b/chrome/content/zotero/xpcom/sync/syncEventListeners.js
index f7a18c5ff8..7597a81391 100644
--- a/chrome/content/zotero/xpcom/sync/syncEventListeners.js
+++ b/chrome/content/zotero/xpcom/sync/syncEventListeners.js
@@ -100,7 +100,6 @@ Zotero.Sync.EventListeners.ChangeListener = new function () {
Zotero.Sync.EventListeners.AutoSyncListener = {
_editTimeout: 3,
- _noteEditTimeout: 15,
_observerID: null,
init: function () {
@@ -168,13 +167,15 @@ Zotero.Sync.EventListeners.AutoSyncListener = {
return;
}
- var noteEdit = false;
- if (type == 'item' && (event == 'add' || event == 'modify' || event == 'index')) {
- // Use a longer timeout for a single note edit, to avoid repeating syncing during typing
- if (ids.length == 1 && (Zotero.Items.get(ids[0]) || {}).itemType == 'note') {
- noteEdit = true;
+ var autoSyncDelay = 0;
+ if (type == 'item') {
+ // Use a different timeout if specified (e.g., for note editing)
+ if (extraData[ids[0]] && extraData[ids[0]].autoSyncDelay) {
+ autoSyncDelay = Math.max(autoSyncDelay, extraData[ids[0]].autoSyncDelay);
}
- else {
+
+ // Check whether file syncing or full-text syncing are necessary
+ if (event == 'add' || event == 'modify' || event == 'index') {
for (let id of ids) {
let item = Zotero.Items.get(id);
if (!item) continue;
@@ -189,7 +190,7 @@ Zotero.Sync.EventListeners.AutoSyncListener = {
}
Zotero.Sync.Runner.setSyncTimeout(
- noteEdit ? this._noteEditTimeout : this._editTimeout,
+ autoSyncDelay || this._editTimeout,
false,
{
libraries: libraries.map(library => library.libraryID),
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
index 9dc2dba41f..36c8a4d4cb 100644
--- a/chrome/content/zotero/zoteroPane.js
+++ b/chrome/content/zotero/zoteroPane.js
@@ -3492,7 +3492,11 @@ var ZoteroPane = new function()
else if (this.collectionsView.selectedTreeRow.isCollection()) {
item.addToCollection(this.collectionsView.selectedTreeRow.ref.id);
}
- var itemID = yield item.saveTx();
+ var itemID = yield item.saveTx({
+ notifierData: {
+ autoSyncDelay: Zotero.Notes.AUTO_SYNC_DELAY
+ }
+ });
yield this.selectItem(itemID);