Fix auto-syncing of unchecked groups after object change
This commit is contained in:
parent
6d2c72fb54
commit
225215842d
|
@ -126,27 +126,25 @@ Zotero.Sync.EventListeners.AutoSyncListener = {
|
|||
// Only trigger sync for certain types
|
||||
//
|
||||
// TODO: settings, full text
|
||||
if (Zotero.DataObjectUtilities.getTypes().indexOf(type) == -1) {
|
||||
if (!Zotero.DataObjectUtilities.getTypes().includes(type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine affected libraries so only those can be synced
|
||||
let libraryIDs = new Set();
|
||||
if (Zotero.DataObjectUtilities.getTypes().indexOf(type) != -1) {
|
||||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(type);
|
||||
ids.forEach(id => {
|
||||
let lk = objectsClass.getLibraryAndKeyFromID(id);
|
||||
if (lk && Zotero.Libraries.get(lk.libraryID).syncable) {
|
||||
libraryIDs.add(lk.libraryID);
|
||||
let libraries = [];
|
||||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(type);
|
||||
ids.forEach(id => {
|
||||
let lk = objectsClass.getLibraryAndKeyFromID(id);
|
||||
if (lk) {
|
||||
let library = Zotero.Libraries.get(lk.libraryID);
|
||||
if (library.syncable) {
|
||||
libraries.push(library);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Don't include skipped libraries
|
||||
var skipped = new Set(Zotero.Sync.Data.Local.getSkippedLibraries());
|
||||
libraryIDs = Array.from(libraryIDs.values()).filter(id => !skipped.has(id));
|
||||
|
||||
if (!libraryIDs.length) {
|
||||
libraries = Zotero.Sync.Data.Local.filterSkippedLibraries(libraries);
|
||||
if (!libraries.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -154,7 +152,7 @@ Zotero.Sync.EventListeners.AutoSyncListener = {
|
|||
this._editTimeout,
|
||||
false,
|
||||
{
|
||||
libraries: libraryIDs
|
||||
libraries: libraries.map(library => library.libraryID)
|
||||
}
|
||||
);
|
||||
},
|
||||
|
|
|
@ -332,6 +332,24 @@ Zotero.Sync.Data.Local = {
|
|||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {Zotero.Library[]} libraries
|
||||
* @return {Zotero.Library[]}
|
||||
*/
|
||||
filterSkippedLibraries: function (libraries) {
|
||||
var skippedLibraries = this.getSkippedLibraries();
|
||||
var skippedGroups = this.getSkippedGroups();
|
||||
|
||||
return libraries.filter((library) => {
|
||||
var libraryType = library.libraryType;
|
||||
if (libraryType == 'group') {
|
||||
return !skippedGroups.includes(library.groupID);
|
||||
}
|
||||
return !skippedLibraries.includes(library.libraryID);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @return {nsILoginInfo|false}
|
||||
*/
|
||||
|
|
|
@ -38,7 +38,7 @@ describe("Zotero.Sync.EventListeners", function () {
|
|||
var expectation = mock.expects("setSyncTimeout").never();
|
||||
|
||||
var group = yield createGroup();
|
||||
Zotero.Prefs.set('sync.librariesToSkip', JSON.stringify(["L" + group.libraryID]));
|
||||
Zotero.Prefs.set('sync.librariesToSkip', JSON.stringify(["G" + group.groupID]));
|
||||
yield createDataObject('item', { libraryID: group.libraryID });
|
||||
|
||||
yield Zotero.Promise.delay(10);
|
||||
|
|
Loading…
Reference in New Issue
Block a user