Don't select new feeds or groups during sync

This commit is contained in:
Dan Stillman 2017-06-16 05:40:04 -04:00
parent 69041832e7
commit 2e74cd7831
6 changed files with 32 additions and 23 deletions

View file

@ -259,8 +259,10 @@ Zotero.CollectionTreeView.prototype.refresh = Zotero.Promise.coroutine(function*
});
/*
* Redisplay everything
/**
* Refresh tree and invalidate
*
* See note for refresh() for requirements of calling code
*/
Zotero.CollectionTreeView.prototype.reload = function()
{
@ -433,13 +435,11 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
}
this._removeRow(row);
yield this._addSortedRow('collection', id);
if (!extraData[id].skipSelect) {
yield this.selectByID(currentTreeRow.id);
if (reopen) {
let newRow = this.getRowIndexByID(rowID);
if (!this.isContainerOpen(newRow)) {
yield this.toggleOpenState(newRow);
}
yield this.selectByID(currentTreeRow.id);
if (reopen) {
let newRow = this.getRowIndexByID(rowID);
if (!this.isContainerOpen(newRow)) {
yield this.toggleOpenState(newRow);
}
}
}
@ -484,17 +484,13 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
break;
case 'group':
if (ids.length != 1) {
case 'feed':
if (type == 'groups' && ids.length != 1) {
Zotero.logError("WARNING: Multiple groups shouldn't currently be added "
+ "together in collectionTreeView::notify()")
}
yield this.reload();
yield this.selectByID(currentTreeRow.id);
break;
case 'feed':
yield this.reload();
yield this.selectByID("L" + id);
yield this.selectByID(selectRow ? "L" + id : currentTreeRow.id);
break;
}
}

View file

@ -276,7 +276,9 @@ Zotero.Feed.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
+ "VALUES (" + Array(params.length).fill('?').join(', ') + ")";
yield Zotero.DB.queryAsync(sql, params);
Zotero.Notifier.queue('add', 'feed', this.libraryID, env.options.notifierQueue);
Zotero.Notifier.queue(
'add', 'feed', this.libraryID, env.notifierData, env.options.notifierQueue
);
}
else if (changedCols.length) {
let sql = "UPDATE feeds SET " + changedCols.map(v => v + '=?').join(', ')
@ -285,7 +287,9 @@ Zotero.Feed.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
yield Zotero.DB.queryAsync(sql, params);
if (!env.options.skipNotifier) {
Zotero.Notifier.queue('modify', 'feed', this.libraryID, env.options.notifierQueue);
Zotero.Notifier.queue(
'modify', 'feed', this.libraryID, env.notifierData, env.options.notifierQueue
);
}
}
else {

View file

@ -137,7 +137,9 @@ Zotero.Feeds = new function() {
// This could potentially be a massive list, so we save in a transaction.
yield Zotero.DB.executeTransaction(function* () {
for (let feed of newFeeds) {
yield feed.save();
yield feed.save({
skipSelect: true
});
}
});
// Finally, update
@ -190,7 +192,9 @@ Zotero.Feeds = new function() {
obj.cleanupUnreadAfter = json[url][2];
}
let feed = new Zotero.Feed(obj);
yield feed.save();
yield feed.saveTx({
skipSelect: true
});
}
});

View file

@ -198,7 +198,7 @@ Zotero.Group.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
+ "VALUES (" + Array(params.length).fill('?').join(', ') + ")";
yield Zotero.DB.queryAsync(sql, params);
Zotero.Notifier.queue('add', 'group', this.groupID);
Zotero.Notifier.queue('add', 'group', this.groupID, env.notifierData);
}
else if (changedCols.length) {
let sql = "UPDATE groups SET " + changedCols.map(v => v + '=?').join(', ')
@ -207,7 +207,7 @@ Zotero.Group.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
yield Zotero.DB.queryAsync(sql, params);
if (!env.options.skipNotifier) {
Zotero.Notifier.queue('modify', 'group', this.groupID);
Zotero.Notifier.queue('modify', 'group', this.groupID, env.notifierData);
}
}
else {

View file

@ -445,6 +445,9 @@ Zotero.Library.prototype.save = Zotero.Promise.coroutine(function* (options) {
try {
env.notifierData = {};
if (env.options.skipSelect) {
env.notifierData.skipSelect = true;
}
// Create transaction
if (env.options.tx) {

View file

@ -527,7 +527,9 @@ Zotero.Sync.Runner_Module = function (options = {}) {
group.version = info.version;
group.archived = false;
group.fromJSON(info.data, Zotero.Users.getCurrentUserID());
yield group.saveTx();
yield group.saveTx({
skipSelect: true
});
// Add group to library list
libraries.push(group.libraryID);