commit bee32d1a51a8c6fc4aefdc0dc5b602777f67f2c6
parent 7cf0ff2683d16e080c2ed716d539b311518f5677
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 24 Apr 2016 19:58:44 -0400
Remove merged items from duplicates view without regenerating list
Diffstat:
3 files changed, 40 insertions(+), 45 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js
@@ -460,6 +460,9 @@ Zotero.Items = new function() {
item.save();
+ // Hack to remove master item from duplicates view without recalculating duplicates
+ Zotero.Notifier.trigger('removeDuplicatesMaster', 'item', item.id);
+
Zotero.DB.commitTransaction();
}
diff --git a/chrome/content/zotero/xpcom/duplicates.js b/chrome/content/zotero/xpcom/duplicates.js
@@ -101,6 +101,8 @@ Zotero.Duplicates.prototype._getObjectFromID = function (id) {
Zotero.Duplicates.prototype._findDuplicates = function () {
+ Zotero.debug("Finding duplicates");
+
var start = Date.now();
var self = this;
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -551,58 +551,48 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
this._treebox.beginUpdateBatch();
if ((action == 'remove' && !itemGroup.isLibrary(true))
- || action == 'delete' || action == 'trash') {
-
- // On a delete in duplicates mode, just refresh rather than figuring
- // out what to remove
- if (itemGroup.isDuplicates()) {
- previousRow = this._itemRowMap[ids[0]];
- this.refresh();
- madeChanges = true;
- sort = true;
- }
- else {
- // Since a remove involves shifting of rows, we have to do it in order,
- // so sort the ids by row
- var rows = [];
- for (var i=0, len=ids.length; i<len; i++) {
- if (action == 'delete' || action == 'trash' ||
- !itemGroup.ref.hasItem(ids[i])) {
- let row = this._itemRowMap[ids[i]];
-
- // Row might already be gone (e.g. if this is a child and
- // 'modify' was sent to parent)
- if (row == undefined) {
- continue;
- }
-
- rows.push(row);
-
- // Remove child items of removed parents
- if (this.isContainer(row) && this.isContainerOpen(row)) {
- while (++row < this.rowCount && this.getLevel(row) > 0) {
- rows.push(row);
- }
+ || action == 'delete' || action == 'trash'
+ || (action == 'removeDuplicatesMaster' && itemGroup.isDuplicates())) {
+ // Since a remove involves shifting of rows, we have to do it in order,
+ // so sort the ids by row
+ var rows = [];
+ for (var i=0, len=ids.length; i<len; i++) {
+ if (action == 'delete' || action == 'trash' || action == 'removeDuplicatesMaster' ||
+ !itemGroup.ref.hasItem(ids[i])) {
+ let row = this._itemRowMap[ids[i]];
+
+ // Row might already be gone (e.g. if this is a child and
+ // 'modify' was sent to parent)
+ if (row == undefined) {
+ continue;
+ }
+
+ rows.push(row);
+
+ // Remove child items of removed parents
+ if (this.isContainer(row) && this.isContainerOpen(row)) {
+ while (++row < this.rowCount && this.getLevel(row) > 0) {
+ rows.push(row);
}
}
}
+ }
+
+ if (rows.length > 0) {
+ rows.sort(function(a,b) { return a-b });
- if (rows.length > 0) {
- rows.sort(function(a,b) { return a-b });
-
- for(var i=0, len=rows.length; i<len; i++)
+ for(var i=0, len=rows.length; i<len; i++)
+ {
+ var row = rows[i];
+ if(row != null)
{
- var row = rows[i];
- if(row != null)
- {
- this._hideItem(row-i);
- this._treebox.rowCountChanged(row-i,-1);
- }
+ this._hideItem(row-i);
+ this._treebox.rowCountChanged(row-i,-1);
}
-
- madeChanges = true;
- sort = true;
}
+
+ madeChanges = true;
+ sort = true;
}
}
else if (action == 'modify')