Skip to content

Commit

Permalink
Select parent item after metadata retrieval if only PDF was selected
Browse files Browse the repository at this point in the history
TODO: select all parents
  • Loading branch information
dstillman committed Mar 9, 2018
1 parent 16ad422 commit 6c8cf71
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions chrome/content/zotero/xpcom/recognizePDF.js
Expand Up @@ -349,6 +349,16 @@ Zotero.RecognizePDF = new function () {
throw new Zotero.Exception.Alert('recognizePDF.error');
}

var zp = Zotero.getActiveZoteroPane();
var selectParent = false;
if (zp) {
let selected = zp.getSelectedItems();
if (selected.length) {
// If only the PDF was selected, select the parent when we're done
selectParent = selected.length == 1 && selected[0] == attachment;
}
}

let parentItem = await _recognize(attachment);
if (!parentItem) {
return null;
Expand Down Expand Up @@ -387,6 +397,18 @@ Zotero.RecognizePDF = new function () {
await attachment.saveTx();
}

try {
zp = Zotero.getActiveZoteroPane();
if (zp) {
if (selectParent) {
await zp.selectItem(parentItem.id);
}
}
}
catch (e) {
Zotero.logError(e);
}

_newItems.set(
parentItem,
{
Expand Down

0 comments on commit 6c8cf71

Please sign in to comment.