Skip to content

Commit

Permalink
Don't select new feeds or groups during sync
Browse files Browse the repository at this point in the history
  • Loading branch information
dstillman committed Jun 16, 2017
1 parent 6904183 commit 2e74cd7
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
28 changes: 12 additions & 16 deletions chrome/content/zotero/xpcom/collectionTreeView.js
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
8 changes: 6 additions & 2 deletions chrome/content/zotero/xpcom/data/feed.js
Expand Up @@ -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(', ')
Expand All @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions chrome/content/zotero/xpcom/data/feeds.js
Expand Up @@ -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
Expand Down Expand Up @@ -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
});
}
});

Expand Down
4 changes: 2 additions & 2 deletions chrome/content/zotero/xpcom/data/group.js
Expand Up @@ -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(', ')
Expand All @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions chrome/content/zotero/xpcom/data/library.js
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion chrome/content/zotero/xpcom/sync/syncRunner.js
Expand Up @@ -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);
Expand Down

0 comments on commit 2e74cd7

Please sign in to comment.