refresh library tab's icon cache on update (#4387)

When tabs' state is updated, refresh library tab's icon.
Do not skip it if the icon already exists (as for reader tabs).
Otherwise, when selected row from collectionTree changes,
the icons in the library tab will not update.

Fixes: #4385
This commit is contained in:
abaevbog 2024-07-13 12:46:33 -07:00 committed by GitHub
parent b16bbc4a8a
commit ac1cb29c69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -96,9 +96,6 @@ var Zotero_Tabs = new function () {
this._update = function () { this._update = function () {
// Go through all tabs and try to save their icons to tab.data // Go through all tabs and try to save their icons to tab.data
for (let tab of this._tabs) { for (let tab of this._tabs) {
// If the icon was earlier cached, skip this tab
if (tab.data.icon) continue;
// Find the icon for the library tab // Find the icon for the library tab
if (tab.id === 'zotero-pane') { if (tab.id === 'zotero-pane') {
let index = ZoteroPane.collectionsView?.selection?.focused; let index = ZoteroPane.collectionsView?.selection?.focused;
@ -107,7 +104,7 @@ var Zotero_Tabs = new function () {
tab.data.icon = iconName; tab.data.icon = iconName;
} }
} }
else { else if (!tab.data.icon) {
// Try to fetch the icon for the reader tab // Try to fetch the icon for the reader tab
try { try {
let item = Zotero.Items.get(tab.data.itemID); let item = Zotero.Items.get(tab.data.itemID);
@ -115,8 +112,6 @@ var Zotero_Tabs = new function () {
} }
catch (e) { catch (e) {
// item might not yet be loaded, we will get the right icon on the next update // item might not yet be loaded, we will get the right icon on the next update
// but until then use a default placeholder
tab.data.icon = null;
} }
} }
} }