From 79feeaecb17a82014f140d8f9598bdfd40c2ed87 Mon Sep 17 00:00:00 2001 From: abaevbog Date: Tue, 8 Apr 2025 19:42:56 -0700 Subject: [PATCH] load all tabs items' data when restoring tab state (#5193) This fixes the breakage in tabs menu on initial load if one of the tab is for an item from not-loaded group. Now, every component relying on tab items (e.g. tabs menu) can just assume that items are all loaded. Fixes: #5192 --- chrome/content/zotero/tabs.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/tabs.js b/chrome/content/zotero/tabs.js index 355c13fe9b..5c5139d0e2 100644 --- a/chrome/content/zotero/tabs.js +++ b/chrome/content/zotero/tabs.js @@ -228,7 +228,8 @@ var Zotero_Tabs = new function () { }); }; - this.restoreState = function (tabs) { + this.restoreState = async function (tabs) { + let itemIDs = []; for (let i = 0; i < tabs.length; i++) { let tab = tabs[i]; if (tab.type === 'library') { @@ -250,11 +251,17 @@ var Zotero_Tabs = new function () { data: tab.data, select: tab.selected }); + itemIDs.push(tab.data.itemID); } } } // Unset the previously selected tab id, because it was set when restoring tabs this._prevSelectedID = null; + // Some items may belong to groups that are not yet loaded. Load them here so that + // every component related to tabs (e.g. tabs menu) does not have to handle + // potentially not-yet-loaded items. + let items = await Zotero.Items.getAsync(itemIDs); + await Zotero.Items.loadDataTypes(items); }; /**