From 764dd1a9da10b3ab707d1df336cf5748a3c93eba Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 5 Mar 2025 22:44:26 -0500 Subject: [PATCH] Take object instead of id in Utilities.Internal.showInLibrary() Not updating quickFormat.js, since we'll be removing that --- .../integration/citationDialog/popupHandler.mjs | 4 ++-- .../content/zotero/integration/citationExplorer.js | 2 +- chrome/content/zotero/xpcom/utilities_internal.js | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/integration/citationDialog/popupHandler.mjs b/chrome/content/zotero/integration/citationDialog/popupHandler.mjs index 8bf64a5af0..d26e5f83f2 100644 --- a/chrome/content/zotero/integration/citationDialog/popupHandler.mjs +++ b/chrome/content/zotero/integration/citationDialog/popupHandler.mjs @@ -71,7 +71,7 @@ export class CitationDialogPopupsHandler { this._getNode("#itemDetails .show").addEventListener("click", (_) => { this.discardItemDetailsEdits = true; this._getNode("#itemDetails").hidePopup(); - Zotero.Utilities.Internal.showInLibrary(this.item.id); + Zotero.Utilities.Internal.showInLibrary(this.item); }); this._getNode("#itemDetails .done").addEventListener("click", (_) => { this._getNode("#itemDetails").hidePopup(); @@ -232,7 +232,7 @@ export class CitationDialogPopupsHandler { } // Show in library if (result == 2) { - Zotero.Utilities.Internal.showInLibrary(item.id); + Zotero.Utilities.Internal.showInLibrary(item); return false; } // Checked "Do not warn about this item" diff --git a/chrome/content/zotero/integration/citationExplorer.js b/chrome/content/zotero/integration/citationExplorer.js index ab9dac1499..492711154d 100644 --- a/chrome/content/zotero/integration/citationExplorer.js +++ b/chrome/content/zotero/integration/citationExplorer.js @@ -362,7 +362,7 @@ window.ZoteroDocumentCitations = { this.onItemRelink(); } else { - await Zotero.Utilities.Internal.showInLibrary(item.id); + await Zotero.Utilities.Internal.showInLibrary(item); } }, diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 03248f8db8..1e646ccb97 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1737,7 +1737,12 @@ Zotero.Utilities.Internal = { }, - showInLibrary: async function (itemID) { + /** + * Select an object in the library tab of the main window + * + * @param {Zotero.DataObject} - Data object (e.g., Zotero.Item) to select + */ + showInLibrary: async function (dataObject) { var pane = Zotero.getActiveZoteroPane(); // Open main window if it's not open (Mac) if (!pane) { @@ -1751,7 +1756,12 @@ Zotero.Utilities.Internal = { }); pane = win.ZoteroPane; } - pane.selectItem(itemID); + if (dataObject instanceof Zotero.Item) { + pane.selectItem(dataObject.id); + } + else { + throw new Error("Unimplemented"); + } // Pull window to foreground Zotero.Utilities.Internal.activate(pane.document.defaultView);