From 6c8cf71c9ad9509b6210cb8b1fcb99a334600277 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 9 Mar 2018 06:39:27 -0500 Subject: [PATCH] Select parent item after metadata retrieval if only PDF was selected TODO: select all parents --- chrome/content/zotero/xpcom/recognizePDF.js | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/chrome/content/zotero/xpcom/recognizePDF.js b/chrome/content/zotero/xpcom/recognizePDF.js index 23f4c96a9..778c8efb9 100644 --- a/chrome/content/zotero/xpcom/recognizePDF.js +++ b/chrome/content/zotero/xpcom/recognizePDF.js @@ -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; @@ -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, {