Remove merged items from duplicates view without regenerating list

This commit is contained in:
Dan Stillman 2016-04-24 19:58:44 -04:00
parent 7cf0ff2683
commit bee32d1a51
3 changed files with 43 additions and 48 deletions

View file

@ -460,6 +460,9 @@ Zotero.Items = new function() {
item.save(); item.save();
// Hack to remove master item from duplicates view without recalculating duplicates
Zotero.Notifier.trigger('removeDuplicatesMaster', 'item', item.id);
Zotero.DB.commitTransaction(); Zotero.DB.commitTransaction();
} }

View file

@ -101,6 +101,8 @@ Zotero.Duplicates.prototype._getObjectFromID = function (id) {
Zotero.Duplicates.prototype._findDuplicates = function () { Zotero.Duplicates.prototype._findDuplicates = function () {
Zotero.debug("Finding duplicates");
var start = Date.now(); var start = Date.now();
var self = this; var self = this;

View file

@ -551,58 +551,48 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
this._treebox.beginUpdateBatch(); this._treebox.beginUpdateBatch();
if ((action == 'remove' && !itemGroup.isLibrary(true)) if ((action == 'remove' && !itemGroup.isLibrary(true))
|| action == 'delete' || action == 'trash') { || action == 'delete' || action == 'trash'
|| (action == 'removeDuplicatesMaster' && itemGroup.isDuplicates())) {
// On a delete in duplicates mode, just refresh rather than figuring // Since a remove involves shifting of rows, we have to do it in order,
// out what to remove // so sort the ids by row
if (itemGroup.isDuplicates()) { var rows = [];
previousRow = this._itemRowMap[ids[0]]; for (var i=0, len=ids.length; i<len; i++) {
this.refresh(); if (action == 'delete' || action == 'trash' || action == 'removeDuplicatesMaster' ||
madeChanges = true; !itemGroup.ref.hasItem(ids[i])) {
sort = true; 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);
}
}
}
} }
else {
// Since a remove involves shifting of rows, we have to do it in order, if (rows.length > 0) {
// so sort the ids by row rows.sort(function(a,b) { return a-b });
var rows = [];
for (var i=0, len=ids.length; i<len; i++) { for(var i=0, len=rows.length; i<len; i++)
if (action == 'delete' || action == 'trash' || {
!itemGroup.ref.hasItem(ids[i])) { var row = rows[i];
let row = this._itemRowMap[ids[i]]; if(row != null)
{
// Row might already be gone (e.g. if this is a child and this._hideItem(row-i);
// 'modify' was sent to parent) this._treebox.rowCountChanged(row-i,-1);
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) { madeChanges = true;
rows.sort(function(a,b) { return a-b }); sort = true;
for(var i=0, len=rows.length; i<len; i++)
{
var row = rows[i];
if(row != null)
{
this._hideItem(row-i);
this._treebox.rowCountChanged(row-i,-1);
}
}
madeChanges = true;
sort = true;
}
} }
} }
else if (action == 'modify') else if (action == 'modify')