Fix context pane lazy load (#4591)

fix: #4548
This commit is contained in:
windingwind 2024-08-20 12:08:41 +08:00 committed by GitHub
parent f53ce16b8b
commit d54f5e516f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -130,10 +130,7 @@
}
}
_handleTabAdd(action, type, ids, extraData) {
let data = extraData[ids[0]];
this._addItemContext(ids[0], data.itemID, data.type);
}
_handleTabAdd(_action, _type, _ids, _extraData) {}
_handleTabClose(action, type, ids) {
for (let id of ids) {
@ -183,9 +180,13 @@
_contextPane.setAttribute('collapsed', !(_contextPaneSplitter.getAttribute('state') != 'collapsed'));
this._sidenav.hidden = false;
let data = Zotero_Tabs._tabs.find(tab => tab.id === ids[0]).data;
await this._addItemContext(ids[0], data.itemID, data.type);
this._selectItemContext(tabID);
}
this._selectItemContext(tabID);
ZoteroContextPane.update();
}
@ -274,6 +275,10 @@
}
async _addItemContext(tabID, itemID, _tabType = "") {
if (this._getItemContext(tabID)) {
return;
}
let { libraryID } = Zotero.Items.getLibraryAndKeyFromID(itemID);
let library = Zotero.Libraries.get(libraryID);
await library.waitForDataLoad('item');