Specify note auto-sync timeout in save call, not in sync event listener
This will allow other operations to specify a longer timeout.
This commit is contained in:
parent
808b71832e
commit
9a47f74787
5 changed files with 30 additions and 13 deletions
|
@ -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);
|
||||
|
|
|
@ -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 '<div class="zotero-note znv1"></div>'; });
|
||||
this.__defineGetter__("notePrefix", function () { return '<div class="zotero-note znv1">'; });
|
||||
this.__defineGetter__("noteSuffix", function () { return '</div>'; });
|
||||
|
||||
this._editorInstances = [];
|
||||
|
||||
/**
|
||||
* Return first line (or first MAX_LENGTH characters) of note content
|
||||
**/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue