From 2e74cd7831665a217c9f442294c99b48ec2b6924 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 16 Jun 2017 05:40:04 -0400 Subject: [PATCH] Don't select new feeds or groups during sync --- .../zotero/xpcom/collectionTreeView.js | 28 ++++++++----------- chrome/content/zotero/xpcom/data/feed.js | 8 ++++-- chrome/content/zotero/xpcom/data/feeds.js | 8 ++++-- chrome/content/zotero/xpcom/data/group.js | 4 +-- chrome/content/zotero/xpcom/data/library.js | 3 ++ .../content/zotero/xpcom/sync/syncRunner.js | 4 ++- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index a9a0cadc7e..f41626a86c 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -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; } } diff --git a/chrome/content/zotero/xpcom/data/feed.js b/chrome/content/zotero/xpcom/data/feed.js index 21ff215716..8400592095 100644 --- a/chrome/content/zotero/xpcom/data/feed.js +++ b/chrome/content/zotero/xpcom/data/feed.js @@ -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 { diff --git a/chrome/content/zotero/xpcom/data/feeds.js b/chrome/content/zotero/xpcom/data/feeds.js index 10e0873a3c..d2cd3ad9c6 100644 --- a/chrome/content/zotero/xpcom/data/feeds.js +++ b/chrome/content/zotero/xpcom/data/feeds.js @@ -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 + }); } }); diff --git a/chrome/content/zotero/xpcom/data/group.js b/chrome/content/zotero/xpcom/data/group.js index f38d0f269b..596fed8250 100644 --- a/chrome/content/zotero/xpcom/data/group.js +++ b/chrome/content/zotero/xpcom/data/group.js @@ -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 { diff --git a/chrome/content/zotero/xpcom/data/library.js b/chrome/content/zotero/xpcom/data/library.js index d0b0b21e69..6abcb4be0a 100644 --- a/chrome/content/zotero/xpcom/data/library.js +++ b/chrome/content/zotero/xpcom/data/library.js @@ -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) { diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js index 8ad35e8030..c4473047bd 100644 --- a/chrome/content/zotero/xpcom/sync/syncRunner.js +++ b/chrome/content/zotero/xpcom/sync/syncRunner.js @@ -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);